|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 ~: V' h1 w( \ I$ P. w其中有一段如下8 F8 y' ~7 p% Z$ Y
ask turtles with [ infected? = true ]
* s" \3 H+ E3 R9 v0 r我原本以为这句会回传『所有』infected? = true 的 turtle- v4 K1 R$ n3 z$ ~4 n8 {, M
但看结果似乎不是这样。
# V2 q9 ~6 o# D, f; j
: S+ M4 b2 ?7 n! i# }6 o7 T假设所有符合条件的有 5 笔
! N4 z7 Q' Q/ R有时候回传 1 笔,有时回传 3 笔,是不固定的
- O; J' e5 t0 B' H: x7 `# a+ ~1 Y" E回头查语法定义6 G' N( @+ E7 H
with ) V9 E0 X5 \* w
agentset with [reporter]& w2 S0 L* h* u2 v: M/ d& n- `
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.2 Z6 o4 a2 F6 h) R7 b
它只说回传 agents satisfying the given condition9 g( c* I( b9 J* I7 q' k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / ?. X7 n( _# E* O
7 o1 q* F" d, w# q- M' k
想确定一下
* z2 B& i- j! \- H! `, P谢谢!
8 D4 Z' A$ F2 E/ d* ?! k- ^$ a ^ |
|