|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* X7 _3 ^, f4 J5 B3 B: z; l其中有一段如下! ~. E/ P, f! n' B, J5 T
ask turtles with [ infected? = true ] 0 ~. t: h2 @' u0 \ K1 n0 ~; h- I4 K8 W
我原本以为这句会回传『所有』infected? = true 的 turtle
. r- a6 Q# v3 s1 z% V但看结果似乎不是这样。 n# f" G1 z5 V6 [" l y9 b3 B! W l5 h
' L- R$ A8 u/ N/ I; t
假设所有符合条件的有 5 笔$ o6 g4 U9 T2 E t
有时候回传 1 笔,有时回传 3 笔,是不固定的( F. k6 R& A* |. Q) `% f; B
回头查语法定义
* P m# L" X, E+ j9 I9 xwith 6 q! z) V* M3 c9 g' z) j8 d6 ^8 S
agentset with [reporter]
" @8 L0 l" [8 D! ^! p5 yTakes 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.
4 H. \0 C1 x; F# ]' [它只说回传 agents satisfying the given condition
) R% X$ J9 C- r1 f) F* h是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * n3 o+ ^' C& g+ j
. q/ W) A* e" _
想确定一下
: ~- @ }( m2 i# _7 r9 C. n谢谢!
6 c* `9 E3 `6 n u; w* | |
|