|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 l* F4 c4 z- q0 v5 F: |- G其中有一段如下1 D3 K" H+ r3 G+ X
ask turtles with [ infected? = true ] 9 A7 C' X- W' W3 Y
我原本以为这句会回传『所有』infected? = true 的 turtle0 K( e8 `9 I G$ f" Q, z3 y
但看结果似乎不是这样。+ h7 K \" w. M
1 _( U4 T% m- C/ R& @% I假设所有符合条件的有 5 笔
?+ l& [7 R; x @. ^有时候回传 1 笔,有时回传 3 笔,是不固定的
$ K. k! q2 s$ N2 }; f' F0 M" q& X# `回头查语法定义
0 C7 O: v& r+ K" c' Swith 3 H- ^ K3 @3 \! l4 \ z* P
agentset with [reporter]( r9 [$ L; j4 I. Y7 c% n
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.- H1 G: d" y4 ~/ L8 [% g, x; g9 ^
它只说回传 agents satisfying the given condition
0 Y# h1 r/ A6 n p2 f+ q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * A- d" r; K7 o4 p: n
- {! z, S. r" H* @5 h6 x想确定一下0 K* m% U. f7 z
谢谢!
1 e- w9 r0 M8 B |
|