|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 x- N& {1 b1 g
其中有一段如下9 {; Z1 ~' a2 J8 w5 C0 A" D: t6 x
ask turtles with [ infected? = true ]
/ B, l z5 g. N$ y" Q; x我原本以为这句会回传『所有』infected? = true 的 turtle: X: I E3 ]/ m1 J
但看结果似乎不是这样。# j" A1 ?) o. F. |% t4 D8 G
/ M9 o2 g/ T' |" V! ]" q% o
假设所有符合条件的有 5 笔5 [* i$ I; s0 j4 X j
有时候回传 1 笔,有时回传 3 笔,是不固定的
# O& I+ T. w# A4 N6 Y p4 Z回头查语法定义
/ Y4 X3 b2 v- C% \1 J5 U$ `with
, J( P1 H6 O7 N$ hagentset with [reporter]
- E# [. `; ?: i) q, |4 v1 q/ ATakes 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.
" T3 D: _) Q* w+ _. `; k它只说回传 agents satisfying the given condition1 f9 B: ]5 R9 c' Z9 ?% Q$ m
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- ]' F5 L9 t* V$ c4 v c
1 W/ [: l4 m8 |, s# S想确定一下+ r+ }. P9 G! A
谢谢!
1 c! e* F3 d1 i" c" W |
|