|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 t5 \" ~ d( B7 F1 K4 \其中有一段如下: b% f: Q; W9 X. k5 i2 ` U( P
ask turtles with [ infected? = true ] ' {, w" d# F$ n8 h
我原本以为这句会回传『所有』infected? = true 的 turtle) c' e1 L% O+ D: |- K7 J- |
但看结果似乎不是这样。
8 T# T. f$ U& M: d
, g0 A6 i$ } n: J假设所有符合条件的有 5 笔
5 k0 p$ K, ~0 X有时候回传 1 笔,有时回传 3 笔,是不固定的2 m6 _$ k: C4 v1 B9 u
回头查语法定义
' |" `8 e) o" `. ]with / g$ N" x1 U, N* s. |$ m
agentset with [reporter]
; T- v5 k6 D5 U+ @! m' aTakes 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.9 U3 d2 ?! X5 M
它只说回传 agents satisfying the given condition
; K* H, z9 O* g6 n: _是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' }2 A! F# Y0 ^9 [$ w# k# e
1 _! x: L0 Y* V, E3 @7 B6 z想确定一下- V9 [' ]# m Q0 |- O* X0 N
谢谢!9 o6 \: y" Y4 F& X! H
|
|