|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序' Q' _3 Z @( T# O2 n v3 ?
其中有一段如下! q3 J. V9 ?- e0 h/ c
ask turtles with [ infected? = true ] ( a- v3 J9 U2 [5 T. }- {- n
我原本以为这句会回传『所有』infected? = true 的 turtle5 v1 q3 N7 v2 T- j
但看结果似乎不是这样。
; z* Q+ W: F; u: K) ~) _9 `
" `3 q$ J) L! ?: `+ z6 V s假设所有符合条件的有 5 笔! i, Z/ s9 j7 I2 K3 S% u) w
有时候回传 1 笔,有时回传 3 笔,是不固定的* |" G% s# [" _& r
回头查语法定义
n! F2 b* q% O* q) Bwith 6 z7 Z9 O! O0 X9 B
agentset with [reporter]
' O6 E y2 g5 A5 D2 sTakes 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.* N7 ?$ n) R# K* H+ a
它只说回传 agents satisfying the given condition' |( h) L3 B3 H" R6 L5 f
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& l6 z, B* `# G( `5 c s$ I) W A7 y' F( r
想确定一下
; e' I7 F6 R) q& O" z5 w/ U谢谢!7 Q% |8 Q# f0 G/ A/ j& V/ j- s
|
|