|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! a8 e& O- I3 p4 i% E3 r其中有一段如下+ ~8 P% h& a2 u1 q
ask turtles with [ infected? = true ] + B& g5 U# z5 h* a
我原本以为这句会回传『所有』infected? = true 的 turtle
# P7 v$ e6 D: I6 ]( Q但看结果似乎不是这样。' [1 c) V" J: I' H+ t
; X0 |& q- h& M+ m7 w0 @: n: J
假设所有符合条件的有 5 笔
6 D1 K5 J# {/ W" x& o/ Z有时候回传 1 笔,有时回传 3 笔,是不固定的; ]' r$ j, b' s/ G. B- b
回头查语法定义
6 [! O& R) J) u) ?" Rwith & p- D+ ~9 k( d' v, S
agentset with [reporter]
x+ M* k W9 i9 m' T" ^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.8 K' b1 |7 c% ~/ j0 U n
它只说回传 agents satisfying the given condition
; _5 _( l8 K. e1 g2 q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( U8 e; c8 K' E5 D4 V" d+ V( u* T8 ^5 |' x* @# e! \# t1 F% B
想确定一下
; w; w$ x5 A! t4 f& c9 u谢谢!
. \; P; [$ G. w" Q2 h! J6 b |
|