|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% z% M$ n7 H4 s! s8 k+ K
其中有一段如下+ Z8 L& ~) l% L' l$ `2 \
ask turtles with [ infected? = true ]
) C6 e& \( R* N* m我原本以为这句会回传『所有』infected? = true 的 turtle# |* ]; g' K7 Q) [8 u6 S' L
但看结果似乎不是这样。) g( G k. ^3 E8 y6 H8 @
5 |: l# E8 K3 l# @. e
假设所有符合条件的有 5 笔# h3 K6 V1 j( K: K3 e6 M
有时候回传 1 笔,有时回传 3 笔,是不固定的- I5 ]" e- Q( b- m
回头查语法定义8 ?4 ?; q/ O0 D; n& A3 I# I
with 5 V" [; M1 P: w- d6 o: @: Y
agentset with [reporter]
- g2 }1 u: ~; _7 }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.
3 H* I3 O4 N" Q( l& s7 o- D它只说回传 agents satisfying the given condition
3 s- C3 t3 R% f" c! c4 P: w$ G; F是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 j* U% k" ~; ?6 N
# P" z5 w; a/ N2 O( r: f1 E; N9 V9 Y
想确定一下6 P0 w& K2 I' L; S
谢谢!- B& E1 l( X4 h% V- T
|
|