|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- z9 K7 n. m. ?' ]7 J' e0 Q其中有一段如下
1 V& `; v7 j. K! k$ pask turtles with [ infected? = true ] ) ~& @ Z5 P/ Z2 B; `1 O
我原本以为这句会回传『所有』infected? = true 的 turtle- o( x8 Q& p$ Z, X; D# J( s1 w
但看结果似乎不是这样。& z) {- V# n- \! v s1 O/ E
4 s! G I+ @9 |) A0 d* j( r) O
假设所有符合条件的有 5 笔
; @( P$ T- \2 O- h& H有时候回传 1 笔,有时回传 3 笔,是不固定的; Q4 b- \/ B8 J5 J7 b4 p u
回头查语法定义5 x. T! y# u$ A0 w# ^9 W5 X
with / w9 L( L% p6 A8 I; U W
agentset with [reporter]
- m7 k5 B7 e. ~; ATakes 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.
; Q$ P! L4 m& l Z2 |. D" _3 n它只说回传 agents satisfying the given condition0 U! w- ~7 t, l. o$ F }
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! e# H- ^$ U' v0 ^
6 N, n& G2 ^( u& t( R9 {( U! x想确定一下3 c! Q' e, B0 ]1 d" G7 x% f
谢谢!
3 |& O% j2 e$ \. K |
|