|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 F' N& G# V( \3 W5 k9 Q其中有一段如下- h7 c3 Z2 n& p. u/ G9 w
ask turtles with [ infected? = true ] . D- w g, c2 d: Q, I, u4 K
我原本以为这句会回传『所有』infected? = true 的 turtle( Q, Y% z t8 ]* O
但看结果似乎不是这样。
. d I5 q- v' g/ P0 ^( i5 O
* w. E" m: C. R! a8 c- I/ G! C假设所有符合条件的有 5 笔* @% B4 k) L) ?9 e
有时候回传 1 笔,有时回传 3 笔,是不固定的
' A2 v1 c# `) F& R# b6 R回头查语法定义
0 t/ n0 @8 j! I2 V* c- W& Bwith
- g7 s5 d) g7 ]7 O# Eagentset with [reporter]
/ k- {+ t1 w: T5 ^8 [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.. Y5 W) ^0 ~0 b$ k- i
它只说回传 agents satisfying the given condition
. c, { k- w9 d5 c是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# g3 K( f9 ^1 l- F
7 T4 w" U' l4 \- v/ S1 {想确定一下( c- }: K% f7 O' y) Q
谢谢!/ u- L: X$ `* ?* Y# M
|
|