|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& q" Y5 A ~# ?其中有一段如下) q7 o* V- }) v, h Q. }
ask turtles with [ infected? = true ] # e3 M2 ^4 n3 x0 N5 B( x
我原本以为这句会回传『所有』infected? = true 的 turtle" Z) K- J3 h3 x8 N2 v- A! |
但看结果似乎不是这样。
" Z: M% h/ }! N: Y
- U; F; ~- C% c# B8 S6 e假设所有符合条件的有 5 笔
/ x3 ?2 r, L" {! J! d& I6 B+ Z有时候回传 1 笔,有时回传 3 笔,是不固定的
9 }8 w3 i/ S8 n% k% ]3 i回头查语法定义7 m& l4 R4 T: a
with
, V, A! _" r( f G# {6 \agentset with [reporter]
# q2 D1 k @1 t0 P# n3 VTakes 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.
- {" @6 D# {3 E1 X( L3 T" W: l' P它只说回传 agents satisfying the given condition7 y* Q* o U5 |. w$ X- O0 _3 k6 B* N
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 s6 e$ o. U K
, i$ t6 t! G! }: ]# i5 N
想确定一下
! T' E: q }0 M# W* v7 C谢谢!! ~9 _0 p' T" q0 W+ E8 p8 g
|
|