|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* M, V2 O% e2 Z* A* T, S
其中有一段如下" y2 b! i& ]" E, r* E
ask turtles with [ infected? = true ]
. J* ?$ Z. T# g& o6 i, P我原本以为这句会回传『所有』infected? = true 的 turtle0 k1 }+ ^4 p/ b e
但看结果似乎不是这样。
; V. f6 I& G9 l' c- |9 z/ h" @5 Z$ S
假设所有符合条件的有 5 笔$ o n* u, r8 h& N) F% o
有时候回传 1 笔,有时回传 3 笔,是不固定的* p1 E |+ y. H% {
回头查语法定义
- n( `; P* |( S: Gwith 7 `8 k( L5 M: Y l4 c' y4 X# P! X# z
agentset with [reporter]
* {, @' b! ]1 U9 ~! C8 vTakes 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.
8 O- P, x% X" J2 ]它只说回传 agents satisfying the given condition: ~8 y, K/ N# k: }4 H( F
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / E' @$ r7 _/ U1 L
" T/ i( a3 D5 a Q6 \4 _) T/ }
想确定一下2 \3 Z/ [0 ]3 J
谢谢!
( y- a# u3 _4 H { |
|