|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 M& d0 A- L1 v6 c
其中有一段如下5 ^- w4 ~+ `7 _1 z, M, y
ask turtles with [ infected? = true ]
. K$ c. q8 }& h我原本以为这句会回传『所有』infected? = true 的 turtle
5 p% H4 S. @$ \0 h& C$ J! y但看结果似乎不是这样。
4 R0 t2 X( y" l0 c4 `* _+ M# R/ O5 K. k5 y; |
假设所有符合条件的有 5 笔& {$ X) w( C5 X" ~6 u
有时候回传 1 笔,有时回传 3 笔,是不固定的
( z" l% j- K# C回头查语法定义# v O; f$ ~7 Y) r# ]
with - ?/ m# D9 @9 ?0 D" y! R4 j2 j
agentset with [reporter]
! j$ U$ n5 e1 J8 LTakes 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.
8 \( O& z8 A1 t) [它只说回传 agents satisfying the given condition( `2 X8 i Y" S9 @9 j
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 Q6 o0 s! [" e6 o, Y- ?! E8 l+ m! X+ b; V+ t% s2 ^0 @
想确定一下# I2 X, c7 i' r/ L9 k* z2 D/ j
谢谢!: Y' D6 S! ~+ k$ v8 T/ S+ Y$ g
|
|