|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" A- @- t# Y0 u& L+ U( k其中有一段如下 J) \$ ]' V9 z
ask turtles with [ infected? = true ] - L q) ]' H# ] z* K) d
我原本以为这句会回传『所有』infected? = true 的 turtle
: m" d/ [7 a3 x/ o6 @# s" ?但看结果似乎不是这样。# m+ L* `8 [; r# O" M3 y6 ^7 a
x' c l$ r/ W8 y# f; l假设所有符合条件的有 5 笔
! N8 A- _! Y- W4 i8 z+ P有时候回传 1 笔,有时回传 3 笔,是不固定的( Z. Q* b% F# |% ?# }
回头查语法定义
; _( \/ }9 c) y0 mwith 8 h$ D( Y8 D1 n3 I$ [9 v
agentset with [reporter]
6 V/ ?; O: r" O) ^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.1 E2 M8 }4 a2 \. l
它只说回传 agents satisfying the given condition3 V+ g t8 I/ c2 e f
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / v7 ]6 s B8 S' I @; T2 S3 J
4 Q+ b9 x6 ~% B# p
想确定一下( N) O7 `6 |+ }; C7 q6 R0 `* {
谢谢!
8 X X, B2 v1 T! M |
|