|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 r6 o N0 x. P! m. j
其中有一段如下 P* o% Q' B( {; {
ask turtles with [ infected? = true ]
2 b/ p' i p3 |- r我原本以为这句会回传『所有』infected? = true 的 turtle6 r/ @7 b' v9 O8 B4 y
但看结果似乎不是这样。$ M/ A6 G7 |7 \
2 Y1 o1 G, p* T/ R
假设所有符合条件的有 5 笔
6 O/ f. d; q9 w9 ^; a" Y* G有时候回传 1 笔,有时回传 3 笔,是不固定的7 c l) E) n3 ~) i1 P# t
回头查语法定义4 s# Q. F- {' W' M
with
7 f' L5 z* J& Y5 Y/ `agentset with [reporter]
! G( ]9 ~& D# I+ N3 J" {1 z2 d% TTakes 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.
( C9 \8 \8 ` g6 {" \2 H$ k, X它只说回传 agents satisfying the given condition# I( I( F; F& e! \8 K F4 k3 q! T
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( x: Q$ {# S) n6 |9 ^
; k3 m. ^3 J# i. `
想确定一下
2 k8 ?6 _7 {+ U+ Q7 O; x谢谢!
6 c+ O9 ?1 D8 s' c" N$ d* F& z8 q' j |
|