|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# _5 M; C# Y, X. X, h
其中有一段如下9 h, J2 b9 I t+ F. l) T+ r
ask turtles with [ infected? = true ] 9 H, m4 u/ {+ d/ q- L. K" Z" `( f9 J
我原本以为这句会回传『所有』infected? = true 的 turtle
" D5 H$ ]. A2 M* x3 f但看结果似乎不是这样。
; U" w7 D$ G" n6 h, E0 J; Q3 p+ i4 a2 Y
6 T6 u) e: y5 j6 k7 w4 L8 U' F假设所有符合条件的有 5 笔& L7 q; f F8 P( ~/ p
有时候回传 1 笔,有时回传 3 笔,是不固定的
- M: I Z/ P* @' c* g3 G! t5 G& f回头查语法定义$ N+ ]% Q. G# V2 s9 V6 Y P* U7 N
with
1 T+ t$ w a# C) I* h* Iagentset with [reporter] e9 ]# C2 \( t) ~, u
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.# l4 } k c( }9 N4 H
它只说回传 agents satisfying the given condition
! ]5 ]4 Z8 l6 g' Z% B2 J0 s: R7 r& K是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 \; X: X' ~) i, O! p( g# P3 o+ Z" m1 _. f N" I
想确定一下" N" o7 w" Q2 ]- U+ N: {
谢谢!
% b3 G& l. U" J& f. f* s |
|