|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& Z5 Y6 \% L" I# x其中有一段如下
0 v0 `8 U8 p. s% |/ `2 [ask turtles with [ infected? = true ] 5 s: H" ^* ~. J# h0 d2 w/ G
我原本以为这句会回传『所有』infected? = true 的 turtle. d8 F9 W) W2 S1 ^( {
但看结果似乎不是这样。8 ^8 O$ J4 A1 B+ E+ p
+ x$ h6 C5 E8 G6 e* B* Z+ L
假设所有符合条件的有 5 笔
2 {' K7 o9 t {$ p# ^) |+ o有时候回传 1 笔,有时回传 3 笔,是不固定的
) r" G. r: f5 X1 Z+ M; t回头查语法定义% _& g' n7 p' c' R
with
4 C' N1 Z' u* o! z3 B$ Vagentset with [reporter]9 M% K$ v: g8 A6 `
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.: Q7 v; P/ U1 V0 a3 G# N- m
它只说回传 agents satisfying the given condition
! V# e9 z8 e# `8 V# G( A8 P u是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( L s$ x3 H+ m
& Z: q+ H; P0 b4 f; j/ k想确定一下/ [- x2 y7 v6 T% Q+ o4 ]& c
谢谢!! f* V N) `# j/ ]0 |! Z+ A- F
|
|