|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! o; T9 d# b N5 K* x' o/ X
其中有一段如下! {2 g# `2 L- o0 P# I
ask turtles with [ infected? = true ] Q* b* X& w# \* {! Y8 {8 ~) v7 U
我原本以为这句会回传『所有』infected? = true 的 turtle" q1 P3 k; t/ [6 R- z. U
但看结果似乎不是这样。9 r0 t6 n7 N5 X. K" n5 l* p# ?
, c: Y Q) [% Y/ Q$ s( |
假设所有符合条件的有 5 笔- V" O/ {+ J4 x
有时候回传 1 笔,有时回传 3 笔,是不固定的8 W% C# M# N4 J7 Z: n: j
回头查语法定义
9 v9 S/ n$ n& ?( g* r* Q u: Awith
, c6 t5 P( h8 magentset with [reporter]! n3 ~) m0 l5 X* i8 K5 Z# T, }* ` U9 m: |
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 V0 E$ q8 u5 ~! M1 C
它只说回传 agents satisfying the given condition
) `2 K2 T/ n4 V& C& c2 X是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 I0 B: K6 u" I+ K! f
! h9 C* r6 @: U+ A* T. j7 z
想确定一下
2 H, C/ z$ g0 l& J: `谢谢! f& Y0 i) o1 N! F; ~
|
|