|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
' e% s7 }1 y* |) V其中有一段如下+ _; Z: ~$ g& M" A- I
ask turtles with [ infected? = true ] 1 l+ V- X# i! C( A; E' s
我原本以为这句会回传『所有』infected? = true 的 turtle8 r- R0 w9 t J# [/ @0 F2 ]# }
但看结果似乎不是这样。
! u: i8 _+ [$ q# z/ |; a# ~9 D; o0 q
假设所有符合条件的有 5 笔+ M5 j6 V# T1 i T R! n/ L( ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
7 J6 Y. B" t. g9 H' }5 I5 j9 t回头查语法定义' G+ v2 W9 L+ k1 P
with $ b1 N) F8 p+ v5 ^! G" t
agentset with [reporter]% G5 l# n" {# a" _9 h" u/ g
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.2 | R5 W9 j2 _, n& k% _
它只说回传 agents satisfying the given condition( K, |5 L; }8 H
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% o4 l; b2 t2 Q4 O+ o# `% p2 _: L1 ^2 X2 I& C+ G
想确定一下9 O* x& J- ^/ E; O6 j6 T7 e
谢谢!! j! Z; {( p8 V" b& k6 B; J
|
|