|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ M' Q2 E9 c! d% M) _
其中有一段如下6 R1 c0 a1 G1 Y& t4 ]0 B: r
ask turtles with [ infected? = true ] : A- {5 S8 K* B1 o; D4 T
我原本以为这句会回传『所有』infected? = true 的 turtle
/ c' e6 l, i9 q* m2 w' R. U8 i1 A但看结果似乎不是这样。
% B, r8 \7 O/ ^# c4 W3 y+ r1 N; i" o7 @" W4 X. |% [8 ^
假设所有符合条件的有 5 笔
3 N, B& c5 A+ O有时候回传 1 笔,有时回传 3 笔,是不固定的
; y3 \! a8 B, f4 r回头查语法定义. q; g) P0 `6 F8 `0 b' S
with ) Y7 V5 }. i) u6 u) {5 o" R
agentset with [reporter]1 S4 `: v. L: l% P$ d! t
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.) Q8 E' j3 x+ K2 x; c
它只说回传 agents satisfying the given condition1 Y# `0 m: p6 @0 I$ ?/ I+ y) j
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 3 @6 h2 f* m: f! X" a# i$ i: K
. i+ t# p* L, `0 w0 @想确定一下
) N/ [) o8 u4 u% ~8 Z/ t谢谢!
. ~! h9 ]& a6 V; `$ q" r |
|