|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 P: j1 C. @: s' P" S* E& T! U- w其中有一段如下& n# k! Z5 y3 H2 e( N% |2 k- |7 j& A
ask turtles with [ infected? = true ] 8 D u1 q- H' w& M3 }. M C3 r# f
我原本以为这句会回传『所有』infected? = true 的 turtle
" c/ E" W2 e4 I3 J B7 U* m: O% @但看结果似乎不是这样。5 O+ p3 t* S# S5 T
- O( m3 S7 ^* |1 m& Z& i假设所有符合条件的有 5 笔
1 _% l9 j" V- d4 R* z4 X有时候回传 1 笔,有时回传 3 笔,是不固定的, Q) s) K* E9 r: \1 m
回头查语法定义
( L* c3 O L: F0 W e) O2 hwith # o l5 i1 E+ O
agentset with [reporter]2 }0 K1 T1 C8 L9 c5 T* N5 Z2 P
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.
: j/ \2 a! ^1 a9 I+ Z! V( o2 M它只说回传 agents satisfying the given condition: V& q7 [5 V6 p5 E
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' Y# c" H+ G# E6 ?# U C6 o' b9 h
2 M& N4 G. m3 [
想确定一下1 I6 L' P% i/ I# s; r* m3 D
谢谢!" Y2 y& E6 |+ d1 e
|
|