|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 y* h. v/ Y# q% b4 q其中有一段如下% `2 V5 C* q- t, W( _6 g" T
ask turtles with [ infected? = true ]
$ n( T8 c$ ~9 _4 V' U7 }& |: |2 Y我原本以为这句会回传『所有』infected? = true 的 turtle8 ^2 U* {/ m- D, w5 v$ E) _# |
但看结果似乎不是这样。
& ?* C1 F9 q+ i/ r" Q- e5 C' ]+ u* N- e5 F- m7 C
假设所有符合条件的有 5 笔
S( a. l2 P% w( q7 x8 L" u: H+ D有时候回传 1 笔,有时回传 3 笔,是不固定的( a) e3 ?. _/ |) R
回头查语法定义, p6 r/ F+ q$ S1 Y
with
1 X: |( M/ R' d |4 Gagentset with [reporter]
/ ~1 a \+ P) A) Z, Y9 kTakes 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.
; F/ I0 ?8 [, U X b; n- ]& p' P它只说回传 agents satisfying the given condition( T0 y# ` O- A
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 i# h g: G5 R' s# b8 {
( s& R' v3 Q: d( v. H想确定一下
0 r$ A' d/ H* k. ?* U' R1 J ^9 E% B谢谢!
' Z4 q% X8 p" C& i- U5 ^# [' c |
|