|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
9 Y. C* b# \" B4 Rto go9 p4 h3 ^- [4 y* A+ b
if not any? turtles with [not stopped? ] [ stop ] # u# T- D& M/ N4 ~1 S* p; q
ask turtles with [remainder who 5 = 0] [4 I# k# X4 p0 k
set close-mates (turtles with [self != myself])with[
: }6 ^+ P6 `; o2 A' Y' W- x/ E. S& i(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; e% C/ W# `0 U- fand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) n7 H# V/ _6 Q5 X# \" \8 y
and remainder who 5 = 0
9 U8 ~$ ~9 P" \' m# f( d] ; T! t! z( |% v" q0 I
ifelse any? close-mates : R. T$ Q3 Z% \, n+ L1 F7 U# K7 b
[
( @% V% }4 J, Q; _# l0 `2 `# rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& `( @ i7 j' ^' C" Jface closest-one
4 v" E9 K, {- S1 }8 k# H0 u8 l* }rt 180
; ~) Z7 N' |: m" q: y+ F e2 dfd random-float step-size1 {* [- d0 k2 v8 j
avoid-walls5 y; B# Y) B/ l$ x' p. T2 I7 E
set stopped? false]/ T* s( I! o7 R
[set stopped? true] 3 F0 E6 M" D! x* M1 J5 `8 v9 _4 S; D
] |
|