|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 R9 N0 ]7 M4 Z. X. W! u) n9 H% Z. y
其中有一段如下) u; {0 E$ Y9 j. o5 H8 s9 l
ask turtles with [ infected? = true ] 5 T X" \4 R, \ I
我原本以为这句会回传『所有』infected? = true 的 turtle0 }0 K S, U3 W) ]% S
但看结果似乎不是这样。4 L! l+ U9 g' G0 _. N [
9 S7 K: b! A: D% |6 m, w假设所有符合条件的有 5 笔
& M" v# n" J# n有时候回传 1 笔,有时回传 3 笔,是不固定的/ {2 D5 C# {" z$ w
回头查语法定义
; ~4 V1 c! c% |8 O7 ^with
7 @3 }* _: x: `- ~5 iagentset with [reporter]% n; z) K" T) H& w, ^
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.
: t4 m& h+ R. B' K它只说回传 agents satisfying the given condition
$ u0 W L% [" Q8 J是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 \4 H7 F* Q0 A8 Y
; S+ q# K1 v3 B
想确定一下
, G; ]4 J# F' ^谢谢!; ^ A% S) u4 r# P2 k& g
|
|