|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# [4 G4 r3 A+ L: G; p3 E- e' v
其中有一段如下4 X; p, y }8 U6 a1 c3 {- f
ask turtles with [ infected? = true ]
5 P$ b0 f! q9 b' [我原本以为这句会回传『所有』infected? = true 的 turtle6 W( k7 r$ Q6 o. h; y
但看结果似乎不是这样。' V& K0 I1 Z+ w1 g: ~: L J" |$ ]+ ~
# z; ^% ~4 B! T* a% [( C5 W' W5 u假设所有符合条件的有 5 笔: A b \4 I% |; @
有时候回传 1 笔,有时回传 3 笔,是不固定的
( N4 d5 A4 _* `; `% E+ c回头查语法定义
& \, d+ u- d% d* Y( V. Qwith & N0 O) Y; C" j5 Y+ q/ ^# ?
agentset with [reporter]
# v2 G, \% i3 e( p9 KTakes 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.! @' \5 E7 i( W
它只说回传 agents satisfying the given condition4 z& `0 [! a' h1 r7 }
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - {+ E( _. V8 v. L: G# X
; y: D1 ^7 {# U# O( H
想确定一下
% p( o4 N4 V V- e3 r谢谢!
: L2 @- H; o" C" v |
|