|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! }: n8 a+ L( m/ ]+ z! q: h5 M其中有一段如下3 V; J, t/ ~. g& O G s
ask turtles with [ infected? = true ] 7 _4 a" o5 V$ E2 f# U) d
我原本以为这句会回传『所有』infected? = true 的 turtle
* T7 N7 e6 u. {' }: d但看结果似乎不是这样。
; J% o* @8 a: z8 m2 R$ E# \' ^& w' N2 k
假设所有符合条件的有 5 笔
/ F, y( Q. Q. v$ r有时候回传 1 笔,有时回传 3 笔,是不固定的# q* j$ i9 f+ @- U8 m
回头查语法定义
5 {* s7 C" G# m7 Fwith ' Q0 ?0 Z$ v% R- p
agentset with [reporter]
. H _: ]! T5 u7 o' S4 yTakes 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., Q: s* f# r. f
它只说回传 agents satisfying the given condition
( n0 i' n: P6 q8 s是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ d- |, I; [2 L4 {$ E+ u$ p
, L. X% {' i+ ]想确定一下
$ S# X9 z- L' b! R0 r5 ?谢谢!8 ]3 `( `; N/ f2 o9 V# }3 u
|
|