|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# _8 v' c9 P( c$ L" g其中有一段如下- x4 s& u+ L. R# |
ask turtles with [ infected? = true ]
( b4 T& D+ z9 @: X, e! g我原本以为这句会回传『所有』infected? = true 的 turtle8 |- m% V+ D! _, X
但看结果似乎不是这样。
" o e0 p" r, j" g" L7 z) e* A. ^5 K K+ \& |3 Z; x
假设所有符合条件的有 5 笔2 f& D" B0 c; T! R
有时候回传 1 笔,有时回传 3 笔,是不固定的
' D9 c7 |, ^ Q: L9 a9 T" k+ ~; _回头查语法定义9 y7 H' ~" O1 w
with , F% k* ?! |+ u: v
agentset with [reporter]
; }% k: G- B' l( o* y9 v9 X) TTakes 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.
j: L' O8 w) r; N它只说回传 agents satisfying the given condition2 r3 M: y$ E( S% I6 i
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 R' D G! \; ~4 w4 ^( I8 }" [
8 ^$ n( N6 r. \% ~3 y# x0 `. R
想确定一下. O: c- t5 x; ?( @
谢谢!) N4 |. D" h% D9 Y, d* x
|
|