|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& s+ J5 Q5 V3 \其中有一段如下7 g3 a. L$ J- i& f" \% ^7 j; S
ask turtles with [ infected? = true ] & ?- k; i8 |$ q9 j. U
我原本以为这句会回传『所有』infected? = true 的 turtle+ r' ~) e5 c. _% k6 w1 H$ s
但看结果似乎不是这样。% `7 g9 n6 T, b
# o/ j0 S2 s$ t% T假设所有符合条件的有 5 笔" W, }/ _3 E9 q9 M- y9 f6 p
有时候回传 1 笔,有时回传 3 笔,是不固定的, R$ G! l1 ~! G+ G7 _
回头查语法定义
j- ~# v5 U" ywith " {: J4 k p& t1 _. ^" U) w
agentset with [reporter]2 C) w* w: j( o
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.( J9 L) k. x, Z- T; h# X$ w
它只说回传 agents satisfying the given condition
# P& A, ^- G `是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 n! s# J4 _0 j# E6 Z2 L, S3 o
3 L0 O* Q" V+ W; _
想确定一下0 I. W+ ~* H+ z# I0 r Q
谢谢!* g" d2 m$ O9 p
|
|