|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# M7 x" r: B2 `. M其中有一段如下& Z* c! n. M, X2 a& c ?
ask turtles with [ infected? = true ]
9 h: Q' f0 J: z' b! \我原本以为这句会回传『所有』infected? = true 的 turtle
! _) |. ]- L* s8 T2 a; l6 i但看结果似乎不是这样。
3 G7 n& U6 h6 ^* m8 K8 c; A# |6 o% R1 q0 R9 E" \
假设所有符合条件的有 5 笔
* ?; l% z2 M9 o; {. G有时候回传 1 笔,有时回传 3 笔,是不固定的
/ m0 ]5 f" `& H4 }: f) ?回头查语法定义- X" E) b7 {: j* J0 F/ y3 l
with
8 x+ `1 R2 A' K/ R: y5 j. ]# [agentset with [reporter]9 r4 E7 L5 H/ d- g1 O- k8 I
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.! x9 w: k8 w5 n+ o1 v2 X
它只说回传 agents satisfying the given condition
( ?: M; K0 M+ W3 E是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ o8 K; m& B: q7 f) j3 P T' F. @$ {" i9 b3 C( q
想确定一下* t4 _! C" W2 r5 q9 x+ @
谢谢!
. D ]4 i3 V1 c/ i( d. l& O3 H |
|