|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false/ R2 b: g; H/ [# P8 \: j6 k. H
to go
! R) V6 g3 p* p3 C. ]) L3 Kif not any? turtles with [not stopped? ] [ stop ] / @1 n& v5 N+ j$ s7 { k( Q; X+ z
ask turtles with [remainder who 5 = 0] [3 [- m" \9 ^. D! {% Y
set close-mates (turtles with [self != myself])with[
$ v- y0 z5 N, D9 p7 `7 d1 D(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
+ n' \9 E# X1 [7 _( o3 R" Cand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 j6 a7 b# P7 {1 ]+ \* {and remainder who 5 = 0
$ O. F* c0 }3 s g] 6 L/ T* H2 P% ?) e
ifelse any? close-mates
' h* ^! F1 u; P/ e9 @! E[
% U2 T, L( C. I9 lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, U m. R Q0 u, K* y; Uface closest-one
/ F6 c: m" Q8 srt 180
0 [! T- n6 }! e: n+ C; s4 _fd random-float step-size
& o* M8 }9 M) @avoid-walls
4 f' N S; Q$ h) Pset stopped? false]
8 I ]' }; T# |6 z* m; ][set stopped? true] 3 N) J, k# a5 \1 B2 f8 ^
] |
|