|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 ^" ]/ Y6 M( q8 H! H. d6 |其中有一段如下% E/ }- ?! d" p [% [) R" H, X: D4 K
ask turtles with [ infected? = true ] 7 H/ h" ~1 Y; D
我原本以为这句会回传『所有』infected? = true 的 turtle3 e/ o/ |0 h/ h+ E& V5 y/ ~/ T
但看结果似乎不是这样。8 z+ S1 z$ @" C( _! _
2 @1 h/ }4 Q+ F0 t5 M8 D3 y8 j
假设所有符合条件的有 5 笔( I9 _5 l7 S8 d5 N
有时候回传 1 笔,有时回传 3 笔,是不固定的; [; H! Z6 u7 ]. s/ S2 G0 q7 H
回头查语法定义2 t5 d- W% q% }* o* @$ \# _- i
with 0 V }+ a. x( ]$ m/ y
agentset with [reporter]% k7 ?) P/ I b9 ?% \( 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.
! `) w, R% I; E7 _, c% `; @它只说回传 agents satisfying the given condition
* v5 E- C# T9 A9 |/ Y, ]# I是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . J# [( m0 J6 z9 l* X4 o; @
( Y) X( p: f) |: S1 \; _* r6 ]
想确定一下$ c6 X ?7 ~, H9 z: F5 R
谢谢!6 k" V$ C U/ g2 j$ B, E% t4 X8 S/ ?
|
|