|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 I- u& W8 `. q5 G其中有一段如下$ h: E" B, ]. t* g$ r
ask turtles with [ infected? = true ] 0 T1 ~, c3 q" S% w6 M
我原本以为这句会回传『所有』infected? = true 的 turtle
0 [/ ?. G% o9 a0 J5 X5 F: P9 d# H但看结果似乎不是这样。
# p0 [4 K; S! {' m1 F4 J9 ?3 M! C( q9 F3 s
假设所有符合条件的有 5 笔6 f: j. z/ L6 m/ [: A
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ h4 r9 }1 `& q' i7 }0 Q回头查语法定义" e0 x6 m4 d& I$ I* C, c7 J4 j
with : e. K2 V! g7 g
agentset with [reporter]& ]: P7 ]$ j! ?3 v) e# ?
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.
5 n s+ P$ H/ h. Y它只说回传 agents satisfying the given condition3 N' @ d' _: `. \5 z! I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * E! T. L, A4 q$ ^# W1 a9 v6 G \1 P
! j3 [& g. D& \- H1 `想确定一下9 b y$ @# Y c1 J6 a; g- l8 m
谢谢!) f9 J- y8 z" [9 k9 W+ G' _
|
|