|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& f8 Z* |3 Z% _2 m* R- ]. c0 v其中有一段如下9 C# \2 u0 t) R1 b1 N
ask turtles with [ infected? = true ]
9 Z: z/ A4 u4 V$ G, Z6 f8 B我原本以为这句会回传『所有』infected? = true 的 turtle
l j2 ~' m* K S0 ] a3 p! |但看结果似乎不是这样。
5 A: U3 L8 t. g
, U: V) I& B+ J l9 Z假设所有符合条件的有 5 笔
; { e* u( n8 w; c& q! g. u+ M5 P有时候回传 1 笔,有时回传 3 笔,是不固定的; O$ T: u) Y3 V% N, X K2 G- \
回头查语法定义! H( I- p2 X: s7 E) O
with 8 Z8 ]1 T; S4 r' o- T
agentset with [reporter]+ m$ {$ ^/ f* B& b
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.
; v" C7 I* |8 T E9 S# o5 G它只说回传 agents satisfying the given condition
6 Q* _9 D3 h7 u5 }! t是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , j, g: Z, K- K6 M
4 L4 F" M6 K/ X- z# v! h
想确定一下$ G1 k) L& h" e5 d y& L& O7 N
谢谢!
! ?$ F: P; L" f/ G& l) I0 B8 i |
|