|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 V5 L0 F, @; Q6 K0 Y% G, M" [其中有一段如下
2 v( [' k! W: ?ask turtles with [ infected? = true ]
1 p" L2 J$ d* p) R% {我原本以为这句会回传『所有』infected? = true 的 turtle
6 Y/ q( @9 N; a, h% s) f1 |但看结果似乎不是这样。
4 d4 F% J0 ?7 E! s @
( ]4 u6 [3 g% y, i' P假设所有符合条件的有 5 笔6 t6 g. M9 j& N8 P" ]5 c' r+ c
有时候回传 1 笔,有时回传 3 笔,是不固定的9 w, {# ?3 K; v- n& H7 o1 Y
回头查语法定义
V/ }% `: {+ i6 Q3 kwith 5 w; W N. I3 i! j9 [
agentset with [reporter]
% o; S% O( P' Y. a( k. l ~# [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.* E% a+ Q# _9 t T+ B0 I' g
它只说回传 agents satisfying the given condition( o1 e1 T. H, U) n+ y# Y* L/ L& r6 _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * P5 |7 ~1 z. k R9 {4 C8 j6 C6 @
7 R, X) h( x% E2 f3 J+ C2 o/ N5 P3 r想确定一下
- Z1 g! i; O, t- }谢谢!( o: O2 w6 L( v" A. B$ `3 c! o
|
|