|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
2 B3 P3 c6 B' M5 v) d其中有一段如下0 ]! n8 a- p5 f4 q8 ]# X
ask turtles with [ infected? = true ]
# N( d# z: L& M我原本以为这句会回传『所有』infected? = true 的 turtle
e- _. {9 O& ?; Q$ k8 A但看结果似乎不是这样。
v: ]: ]: J- B" p+ ?% k
1 f+ s# |6 `: E假设所有符合条件的有 5 笔' x* g- i7 Z2 A
有时候回传 1 笔,有时回传 3 笔,是不固定的
u q; p) |$ z: n6 T回头查语法定义
2 f# Y$ V- D! ~* q$ G6 ^with 1 t1 O8 f! W5 c8 u' ~$ M( i
agentset with [reporter]+ S2 C8 j! N' y# `/ E: I
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.8 i# v7 P# F" V
它只说回传 agents satisfying the given condition
% R: Z0 C# r6 H% }+ j2 f$ r是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 D0 x; ~$ _7 Q3 y( |4 ?
* G/ @1 K! J; D! [8 ?( M5 y
想确定一下+ ?+ l# o: d/ m/ ~2 D9 h8 |
谢谢!! f1 a: a: D p0 m
|
|