|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* L: {) ~/ e5 ^, k- U0 n+ ~其中有一段如下: H* C: w) o' h) G+ A
ask turtles with [ infected? = true ]
: i( g3 Y2 j; ~3 ~+ M我原本以为这句会回传『所有』infected? = true 的 turtle; w8 ?+ U) _& C% y U
但看结果似乎不是这样。8 j" y }/ L, I
1 ?8 M8 n' c) _# F8 b. L+ Q8 p假设所有符合条件的有 5 笔
4 x6 e' Z6 ^6 |* h8 F' e- t有时候回传 1 笔,有时回传 3 笔,是不固定的- n' N, T9 G+ F( X6 V
回头查语法定义
. S% S+ w$ G* i) d% c3 }with
+ L$ l6 }! E" Q3 {* E, vagentset with [reporter]0 j/ c) H8 ?6 q. @) h o0 V! M
Takes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition./ Q- T# k p% |; X
它只说回传 agents satisfying the given condition
6 Z" _6 O# ]8 i1 n. T; ?3 R是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 R& ?# e" n: F1 C4 }+ T
. h8 m0 y3 }* c/ l. R0 A想确定一下3 B0 o. i% `0 L( \" I u
谢谢!" u' x: B' j6 O" k, m, {6 O: T: d8 Y
|
|