|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ E$ C5 m* s; `4 r$ d4 e
to go
0 N& A8 \, b* zif not any? turtles with [not stopped? ] [ stop ] 5 r, ^6 L9 U! X- @# D. h/ k
ask turtles with [remainder who 5 = 0] [
$ w, W" w Y1 `* E5 Bset close-mates (turtles with [self != myself])with[
; _; k% D4 D/ C0 f+ |" ~2 e(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : a( ?0 p' ~# d' m
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ V+ F- W q3 x- e
and remainder who 5 = 0 1 `4 e* N; ?6 N2 ~% e0 y
]
! a: u Y6 y# Q ]& y% [ifelse any? close-mates
" u! k( ~1 o: D3 |) @5 w[ ( A- A8 l# K. h' j" P
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]7 x+ [9 J- N- Q2 C
face closest-one* e# d* P- n1 b2 n3 q- q
rt 1803 s0 D3 m/ \# t2 i- L- V
fd random-float step-size# a; n# l- H3 n/ b
avoid-walls
6 n+ Y" T2 B$ E8 hset stopped? false]
7 w0 }1 t/ @# P2 ~[set stopped? true]
) x3 e ~* R `9 c4 Y1 U6 ^] |
|