|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 r3 T3 c* T+ i3 I$ \% H# U( F* q
其中有一段如下% [# x9 @4 r* K+ Y( R* u% s
ask turtles with [ infected? = true ]
2 _: z. C) h k, E7 m. s我原本以为这句会回传『所有』infected? = true 的 turtle7 c" U0 Y$ m* o# D. f: m
但看结果似乎不是这样。
5 `$ S1 _9 a/ n
- B/ p" o( z# k* q& m' h假设所有符合条件的有 5 笔0 `8 i @7 X2 M
有时候回传 1 笔,有时回传 3 笔,是不固定的; W# W. V* F8 ^3 \2 Y0 j
回头查语法定义
5 h' x& H% h" H1 G) Pwith " x/ H$ Z6 e# Z9 \
agentset with [reporter]
3 V3 t/ a3 b5 B, l. _' A% F" XTakes 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.& J7 H. |* I& v2 ^
它只说回传 agents satisfying the given condition& R. O9 ~8 ~* z! Y+ L8 i
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 F3 a; [: c7 V: F% J) C: ?. Q
2 B# M) ~: v0 U3 [( ?想确定一下7 _2 ~: \, ` h- i* ]7 K2 w" A) f
谢谢!
& Y+ P" y4 ^! @7 T |
|