|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, u/ u$ s) l) A E其中有一段如下& l# v0 c2 Q6 p. X, G; v, Z! M
ask turtles with [ infected? = true ]
( i# i: `% |5 p, C我原本以为这句会回传『所有』infected? = true 的 turtle
9 G: S. Q( n' g1 f. [但看结果似乎不是这样。' A# N |2 K$ [2 j9 _
% f: v' l: o: t
假设所有符合条件的有 5 笔3 ]1 v9 S# s9 \( [' H
有时候回传 1 笔,有时回传 3 笔,是不固定的' y( R$ h: f$ v* H5 E; K) E8 {
回头查语法定义
6 ?0 L) Z/ g6 z; D5 Wwith 6 b" Q3 I7 s% V+ p
agentset with [reporter]
* R6 E7 [5 H' `+ P2 qTakes 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.. r# t o) T( s% ~
它只说回传 agents satisfying the given condition
: Q2 q' X6 W0 u8 M0 b6 X是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 Q1 d- ?# g9 f1 i9 P% g
5 J# G' z/ i1 c, ~想确定一下2 O( G+ \4 _, T/ o5 I
谢谢!* ]: P; ?5 ^8 W6 }$ p
|
|