|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* Z9 S3 P; f1 Q' C
其中有一段如下% c$ \, ]" n1 }$ v
ask turtles with [ infected? = true ]
* Z% t# q1 M' m4 x* E( ]7 p$ ~我原本以为这句会回传『所有』infected? = true 的 turtle2 l2 |% O0 R# \- W
但看结果似乎不是这样。2 I" n3 N8 M! ^: i% C/ H1 F
5 n) w, [) E9 R; W Y
假设所有符合条件的有 5 笔
3 U8 Z& @8 W6 ~5 c有时候回传 1 笔,有时回传 3 笔,是不固定的6 t/ E) {& i+ \5 r7 v6 l! r
回头查语法定义% A3 @( q! t. y& T2 U) M
with 7 G: g/ u4 Y9 ?; F- r1 K
agentset with [reporter]
' [; M5 B N9 q8 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.- |! ~( b! s" L a0 _5 a- ]! Q
它只说回传 agents satisfying the given condition
+ E {$ b2 }. e4 N是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * I; Q ?4 r6 p2 c# p) `
" ^, D$ A7 E& ?2 V; }! } `0 h
想确定一下9 Q$ ?7 q+ c# f7 g W4 N' v' Y6 n
谢谢!3 V/ S6 U1 C) o& Q! X l
|
|