|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, [4 w: O# z3 T& |! F, [其中有一段如下
1 h: _$ d: l1 }- L2 M4 c5 Y3 {ask turtles with [ infected? = true ] ! Q. K6 b7 F" W+ f+ ^
我原本以为这句会回传『所有』infected? = true 的 turtle
5 q) N) Z* Y" Q但看结果似乎不是这样。
; o# i' \9 u8 ?' u2 ?( }* K! B' U1 j! Z
假设所有符合条件的有 5 笔9 O" i5 j) m+ ^- E5 S, I3 E
有时候回传 1 笔,有时回传 3 笔,是不固定的
9 Z' E4 j) y% Y2 }回头查语法定义" k) f1 B6 F) n# n8 ~0 E- ]* ~
with / E; [3 u1 Q' A
agentset with [reporter]) R$ X5 ~2 W' b1 s* k0 o- v! e
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.
: r! K/ E! E/ C! k它只说回传 agents satisfying the given condition
( d' I( V, V* q# B是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 m. ^( A7 e, _7 T+ X/ s
% t2 A4 u2 ]+ }6 s6 W8 `想确定一下
3 c" |% i; @2 \ y7 ]( X' ^谢谢!
, R6 k* d; ^* K3 t |
|