|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序+ O; X' n- ]3 @- J f# m0 m
其中有一段如下6 B4 G! e) k' W6 Q
ask turtles with [ infected? = true ] ( |2 R A% f: D0 f5 }
我原本以为这句会回传『所有』infected? = true 的 turtle9 ? A( ^0 k7 Y% `" H3 ~
但看结果似乎不是这样。! K3 s3 z! ~0 c2 s$ j* v& `
3 U2 J5 {) \9 z) Q' z* X+ ]& z
假设所有符合条件的有 5 笔
# }9 E) o% r9 Q有时候回传 1 笔,有时回传 3 笔,是不固定的
' d A/ k( u6 D. A& K回头查语法定义
]. m" Y9 i+ a5 D. \with
' k% z; ^5 g4 _9 l: s! Dagentset with [reporter]4 ^$ Y) C- h0 W# M" p, p1 I
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.
- S9 ~/ `+ U/ @3 _7 K: ?; Z* s它只说回传 agents satisfying the given condition4 H" w5 {1 Z' z0 V; g9 p
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; |) e3 W* A5 C U) \
0 J' v9 d# O/ w: O, c' c3 K想确定一下) \- R9 F/ w7 J, C6 Y6 @* c1 T; G! t
谢谢!
. z0 ?! |, ~/ t! B% t |
|