|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: _ {8 _5 B; r t. E其中有一段如下
) U& P7 ?- q2 S# S& ?+ I$ uask turtles with [ infected? = true ] " M& B0 W+ J9 y# G* o
我原本以为这句会回传『所有』infected? = true 的 turtle4 o. a ~6 g. j' }
但看结果似乎不是这样。 w, Z7 z q) P# N3 U! q
& g9 M0 U5 `; F6 _9 C# x p" @ v4 O
假设所有符合条件的有 5 笔$ W2 U& Y" [0 g! ~; ~4 h
有时候回传 1 笔,有时回传 3 笔,是不固定的8 |; H( o* i3 G& x& [
回头查语法定义
A' U1 A2 w) c. E& s" A4 j& g6 {with : R9 \6 J8 d' F( L8 n2 r H
agentset with [reporter]
, V- Z. C7 ^- [; GTakes 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.
& @( T; _# O4 k* a$ A它只说回传 agents satisfying the given condition
! t! Y$ a8 Y, ^, M* L" ?; @( y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ e4 P0 J0 Y* S$ @' I/ n: t s$ A" j/ d
想确定一下$ G* }3 ~, I2 t4 N% ^
谢谢!5 v/ E, m D% l9 a( U% R; a3 O1 J
|
|