|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 o* P% }; M ~+ R4 v
其中有一段如下' a8 g$ r! |( f& l& G
ask turtles with [ infected? = true ]
$ h: w3 \0 p; n! J: Q我原本以为这句会回传『所有』infected? = true 的 turtle
/ P! _3 ~; ~& J$ m' e% G: o# o但看结果似乎不是这样。
; ^9 }6 I( U R+ o5 f2 ^+ R* I, o- \# e b) P4 U
假设所有符合条件的有 5 笔
2 W2 A, E; j& ?: N1 q4 v4 _9 k有时候回传 1 笔,有时回传 3 笔,是不固定的4 Y& j6 l! g6 e* X+ a6 u/ c
回头查语法定义
3 M. j1 D3 P3 a1 ~with 3 X* u+ d. [* y% p# j, R: V {
agentset with [reporter]# J9 ]8 z3 r) d
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.; Y' Z4 k; A1 J
它只说回传 agents satisfying the given condition
6 O2 i6 }1 ^: f- p% H2 |7 f7 I是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; C$ f8 i* D, i7 ? ~8 E: I; d3 B, c& @: d3 H- _* T
想确定一下
8 w$ U6 e" @( h3 ]% {6 s谢谢!* t% v; Q8 z9 b8 c) {3 Z
|
|