|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- o1 a" |1 }& o+ ~: p其中有一段如下3 ~' k; _% _" n' R
ask turtles with [ infected? = true ] 2 z8 a6 \0 Y6 Y7 R
我原本以为这句会回传『所有』infected? = true 的 turtle
; J0 C* [' o% [4 F7 n但看结果似乎不是这样。
$ o6 W3 T! ?, i5 ^ {! U9 m* v6 h; } y! G
假设所有符合条件的有 5 笔. P$ D+ U G) d- ~$ W. q: M% s( [% J
有时候回传 1 笔,有时回传 3 笔,是不固定的' J5 V+ I! t6 z a& {
回头查语法定义
6 y+ s. M5 `: `4 \3 y2 Lwith * Y4 D2 |, Y! h- K) B
agentset with [reporter]5 w. b, y, C0 r# Y6 |5 S+ p
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.' F0 f" G H5 M0 x. O% [* F
它只说回传 agents satisfying the given condition
+ K$ y& g6 p3 {5 L1 _* ^( c% Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! l4 h( K: u8 o5 ^- O0 Q, Q2 x; [
想确定一下9 q% s1 b; h& H: j/ W9 S# P1 t! t, ?
谢谢!
# {) k. w- Q; ?9 \& V8 Q a% \ |
|