|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; {4 n2 L5 e C2 e9 Y5 s# }
其中有一段如下1 r4 w# ^, ^" r$ d2 I. |0 X5 }
ask turtles with [ infected? = true ]
9 D7 J$ f, T: {我原本以为这句会回传『所有』infected? = true 的 turtle
/ Z! P/ R. X% K y: x2 t+ C但看结果似乎不是这样。
5 @+ q: f0 A9 x, c( ?% t0 x, r* f' F) X3 l% l* ~4 L! t
假设所有符合条件的有 5 笔
1 E% z( u2 e- o有时候回传 1 笔,有时回传 3 笔,是不固定的# h/ T4 `! J7 g F t# b, ?" I
回头查语法定义
& @; t3 H% l4 t+ ]2 c" [with ) G# s0 Y, w4 ?! j9 J; _
agentset with [reporter]
! Q$ |; \# P; K& k! W- }6 ~, cTakes 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.
+ L# K8 F9 S+ ]. N8 O0 w它只说回传 agents satisfying the given condition: r* ^% Z) y+ B! P, i' [; W8 Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / x1 ?5 w: [( Z
+ E0 @1 {( s2 n" P) _1 `; ?- n
想确定一下; x3 m: l# q' z8 p5 ~ }4 {
谢谢!
1 `" W/ [- B( I: K/ o |
|