|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; Q: n4 m% Q2 z1 k其中有一段如下; _: [8 j# ?* t( v5 H' [" O
ask turtles with [ infected? = true ] 5 J6 g. g1 \ w, ]
我原本以为这句会回传『所有』infected? = true 的 turtle, E" a. _8 o P8 P$ a- W/ h
但看结果似乎不是这样。4 _ e. w* S2 d! b0 n
, G' H) _, Q5 J) U3 O假设所有符合条件的有 5 笔1 Y3 m, k8 P" ?6 P4 W
有时候回传 1 笔,有时回传 3 笔,是不固定的
$ h V) ^7 \, D回头查语法定义
8 K8 z" I& j& S# \with
" v: f1 [# H+ M1 I' Z1 F. p; I/ Lagentset with [reporter]( b4 O4 G- m3 v2 K; x
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.+ G( G, q9 E; w! T! e
它只说回传 agents satisfying the given condition
' n7 i# ~# e* l' M8 x* l9 r" a" W是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( b7 Q4 W6 B9 E# S8 u9 R
! r" b$ Z$ `$ I" r1 k9 O1 O$ c想确定一下
; b( W3 W4 q( \# [2 F谢谢!" I' ]7 ~7 U* A* V( G. p
|
|