|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 h& w8 H5 ^+ r R. w
其中有一段如下6 n; ^6 X$ ^, v: M
ask turtles with [ infected? = true ]
: r2 s( Q- x/ {+ U* ^( Y0 }我原本以为这句会回传『所有』infected? = true 的 turtle
: [8 D. Q- Z4 h+ H$ R7 E. _3 A但看结果似乎不是这样。* R. R& `6 S$ h6 D/ N; f1 `
+ v6 h) `* R! c T2 P" l" ]
假设所有符合条件的有 5 笔
: Z( ~7 w! @" a6 _) ^有时候回传 1 笔,有时回传 3 笔,是不固定的' e9 k# _- p' d) w4 N
回头查语法定义* w' w7 _$ A( _
with % B; M' u( [" \6 r+ ~
agentset with [reporter]6 p/ x0 x- N' `0 z" A* v
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.
( d. h: d8 o9 y! Q# O4 i* K它只说回传 agents satisfying the given condition
) U" L3 e5 H/ s" a" r D是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) j/ Z) @) S0 K- `! q- F; p
3 l, @9 Y% m z想确定一下3 Y7 N4 |+ l' C* `* P
谢谢!
" J5 N% C. G$ O |
|