|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* K7 i! v8 w9 N5 D' q/ y+ Y. @/ T其中有一段如下0 |0 R$ N n& k3 u) g" x) _
ask turtles with [ infected? = true ] 8 d" h* v4 }1 F" ` E( f
我原本以为这句会回传『所有』infected? = true 的 turtle
0 L1 a' @. v' z6 J5 I# o) \但看结果似乎不是这样。
4 U0 @/ n7 N1 G; P5 A: P/ W8 u6 i3 d3 E
假设所有符合条件的有 5 笔9 _! d0 h3 E$ @2 w5 ^
有时候回传 1 笔,有时回传 3 笔,是不固定的# C1 y; h# z3 e) [- e) b5 m9 ]; S6 `
回头查语法定义
7 B- L/ U" h: r' A# G. vwith
$ ^* t4 _- F6 k R f/ w2 Sagentset with [reporter]
; Y( |! ]9 z2 e4 O# YTakes 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.
/ {( e7 e; k/ ^3 q' Y0 R它只说回传 agents satisfying the given condition5 e, b* c# P3 I' w4 J! C& V
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % I6 m' J! M0 n- a" T
1 t: f6 g+ ?; E! E4 o; L- R想确定一下
: f% S$ L& C/ S4 k谢谢!
8 D3 p x3 E. o' {2 x3 W |
|