|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* d9 J1 ]9 \/ D1 m0 }7 u f0 P0 E
其中有一段如下) @1 D! ?. ^$ X: Y9 b2 l
ask turtles with [ infected? = true ]
& F( u- p5 d3 a0 l* d; c我原本以为这句会回传『所有』infected? = true 的 turtle( @' @/ j) P, D0 [) N7 g7 i6 f4 b
但看结果似乎不是这样。
" }" s1 k4 }: n' S, L% S6 }0 \
7 X0 x3 n4 D! a8 j假设所有符合条件的有 5 笔0 C6 i' `! `+ h- @( v8 \" H
有时候回传 1 笔,有时回传 3 笔,是不固定的9 U& Z- r& B8 [% S& K* \
回头查语法定义
4 f+ X% ]9 ]" X7 v; s, ^with
* F1 \% [9 j Iagentset with [reporter]( ?0 J! S/ O( d5 W4 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.; E4 u5 j# ^* R+ s: D
它只说回传 agents satisfying the given condition
7 i- n; ]) a) `9 F) l4 Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 M2 t, g5 h; z. L# x' F) W
& a$ y7 l: `( _. F" g( U* ]: Z# { L
想确定一下; R# @- O9 C. p- ~! C# Y, E
谢谢!" F. l, \1 j* I; E8 D; M% i
|
|