|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 Y7 a- U% d* W. e4 ^4 p X
其中有一段如下2 B2 Q4 ~$ k' C: L0 Z: q
ask turtles with [ infected? = true ] . @! o# F3 E$ q. o0 K
我原本以为这句会回传『所有』infected? = true 的 turtle( t- x( E0 D2 B
但看结果似乎不是这样。: ]8 U( g& x/ Q" N# Z; F# B7 E
. J7 ?. A& V, z" M4 m
假设所有符合条件的有 5 笔& w4 m6 p0 l8 z" C$ _# f4 l' A* E( |
有时候回传 1 笔,有时回传 3 笔,是不固定的7 W; c3 }) T+ S1 @! C/ \, a- W
回头查语法定义 s9 q6 H) H& ^ K. M5 i% e
with ! a- `9 a# o7 C+ t
agentset with [reporter], C& h U* M; V- ~4 p( |' M7 R% T' Q
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.
4 ^9 L8 q: r K6 i* Y5 e0 K它只说回传 agents satisfying the given condition
8 M9 J P8 y" C" y6 g是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 {& J- p% n [0 v0 O' J
( t! n* ~* C/ Y3 j想确定一下# n- [- N6 Q( ]: w
谢谢!+ Z2 d" d7 A% c
|
|