|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ _, \# N f7 ~) A' |. k+ Y
其中有一段如下7 i) W8 q h0 q2 h- l* @
ask turtles with [ infected? = true ]
; q# E) m0 Q8 j- P- b L$ F8 b我原本以为这句会回传『所有』infected? = true 的 turtle* \9 X: D. ~* q5 ]
但看结果似乎不是这样。
! _3 t+ w" ~% y. R3 c- q* k
3 U/ [! P7 ?) Q假设所有符合条件的有 5 笔; ]' C* Z, J" E1 X3 t
有时候回传 1 笔,有时回传 3 笔,是不固定的7 s% R9 Z! V' E$ y9 ]
回头查语法定义
0 A7 i+ H; Z- n% A3 q) E( uwith n# C$ j; _2 k! a
agentset with [reporter]$ H* G* |& [/ v8 R( B0 t
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.
& e9 l+ ?9 P+ _1 w1 {! `( W它只说回传 agents satisfying the given condition& [) C" D8 R, m4 M) `+ q2 H8 R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " W8 _) `% Y! a! t! }4 `" v
" X9 R* T$ J; O5 p* b想确定一下
, l) `8 G. p$ B6 i" d5 Q& E! T谢谢!, `3 x# k6 O- T% s
|
|