|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 _9 D5 p0 ]+ n4 Z
其中有一段如下* G% d/ m5 \# J p2 B7 _: K
ask turtles with [ infected? = true ]
9 L$ x5 l/ \! `; a! L( P% Q我原本以为这句会回传『所有』infected? = true 的 turtle
/ Q2 M. x$ H4 f. z/ Z0 Q但看结果似乎不是这样。8 U. V: P- C- J6 F( B8 I, a( e" ]
4 _& Y- V: J7 t6 c) T' z假设所有符合条件的有 5 笔
1 x# Y0 R. W7 l8 i4 T J8 p: ~有时候回传 1 笔,有时回传 3 笔,是不固定的
8 T; N4 b6 Z T4 c5 k7 K7 r回头查语法定义
1 z* R" l1 y a9 k1 `with + o: g# w6 V, Q1 D
agentset with [reporter]
0 f1 X% G I: ^6 \6 nTakes 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.5 e8 _' s3 J) }
它只说回传 agents satisfying the given condition& Z% G$ y2 \3 [ c; _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, ?% \ U# ]9 _% N6 {3 V A2 x
, h+ |2 X4 Y/ S$ K想确定一下6 j: e- Q7 h3 M9 h
谢谢!' J+ s+ @6 X* o3 C F; j
|
|