|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ d# t8 K5 t% J {其中有一段如下6 W7 p \2 X6 e/ c; R: q- u
ask turtles with [ infected? = true ] 1 j# _* y0 l1 V H
我原本以为这句会回传『所有』infected? = true 的 turtle; X; W- P+ v* b6 @
但看结果似乎不是这样。" D2 Z% \# D+ Z( C/ P# C
. W' u- P+ I5 N假设所有符合条件的有 5 笔
. T1 l* K X a( F有时候回传 1 笔,有时回传 3 笔,是不固定的. R6 e( d& z/ q C8 C$ v0 n
回头查语法定义
7 n) L& E! d0 \! E/ |& dwith
' Z, C% A# U9 z* T5 T* z, `agentset with [reporter]. V; n" P2 |2 l5 }( s- c( R
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% }* x4 _ {0 i1 u# n [8 h它只说回传 agents satisfying the given condition# B; u- u) y7 ?1 I3 b4 x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 F4 ?4 T2 m, i% _0 C2 i/ `
5 m( g! R8 B S4 @7 p' j1 H想确定一下
3 F; `2 I0 v" m$ g$ W/ N5 B6 K0 ]谢谢!8 F" R% v# \4 u. S; h: w
|
|