|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 C: ~4 ~2 i- m9 {! w, u其中有一段如下) n8 e" a0 R/ [+ |- i8 F5 ~
ask turtles with [ infected? = true ] 0 a8 f' j- ]6 K- J# A, {
我原本以为这句会回传『所有』infected? = true 的 turtle* r5 P" X- K' I& A
但看结果似乎不是这样。+ k: D* ?: w( k% y I! I9 D
. Q' J% a8 ?/ v+ G% f; ~1 W; u0 U; i9 y
假设所有符合条件的有 5 笔8 V# A+ U$ R# ^! l
有时候回传 1 笔,有时回传 3 笔,是不固定的
5 I! d1 M2 {5 ?4 M回头查语法定义
2 |: h- z; r- x, }with
8 t7 [ R1 u& oagentset with [reporter]. x7 _( m, ^+ F$ Y! Q5 w' s
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.
. m# z0 z% V0 p# k它只说回传 agents satisfying the given condition
" ~8 w. ^( ]' F7 E! w! P是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / k s- @7 ^7 v$ v
/ {' F' b& E: |想确定一下
4 A1 A: X( k; U* L; _谢谢!% v$ d5 `: M: ?5 ~) ?& F
|
|