|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
; o( s! ^* V& Q( b; d! T$ |to go, N T1 A/ M+ u: L
if not any? turtles with [not stopped? ] [ stop ]
}9 M0 a' ^" \0 s7 Hask turtles with [remainder who 5 = 0] [4 t! U0 j! y: U b8 b5 V
set close-mates (turtles with [self != myself])with[, y% O' C5 S3 z& G D! t
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - b A: X4 T& K( l
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - H0 A8 `: \+ ?% u
and remainder who 5 = 0
a( X! d/ v0 t4 v s& R]
- ~ t$ ]# H, eifelse any? close-mates # P# v, p* {- k5 \
[
+ r! x) V3 R- E, F' Mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]# H! s9 K" h5 W a
face closest-one% l! f$ o, G9 z- s9 I0 y$ ?
rt 180
* X0 `/ i2 }8 x1 G$ K6 vfd random-float step-size
0 ]$ X, c; U' _7 lavoid-walls! ^8 [8 [1 q: b8 k# `
set stopped? false]
# y, T) s# A& _( ?[set stopped? true]
& t) w: B- f% ?] |
|