|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 k. p2 @! @) P$ p) i3 V$ T
to go
. y7 @; a" k' w9 T6 z2 Pif not any? turtles with [not stopped? ] [ stop ] 1 g+ y* G2 c3 E4 |, M
ask turtles with [remainder who 5 = 0] [- {5 A4 Z' W5 @( `; v+ H
set close-mates (turtles with [self != myself])with[
. f4 `+ m/ w4 F4 ^& E( [, ?% w(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - y% z& \6 E& M* ?7 j, s
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) * T- O! ?6 X3 ]1 ?* a) E6 O( e$ Z
and remainder who 5 = 0
5 Z& u5 @" }% g, _6 R4 b$ t]
0 k, E' a3 z6 p7 k6 oifelse any? close-mates 9 \4 V( [& D$ \
[ ( c& n( A& [, }% A% p P! A* @
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. a# R$ V: d4 v8 g9 o1 c% t; hface closest-one
) g5 O, r4 p: X( ^; m2 \rt 180; V: z. W0 \7 o5 W/ L6 T
fd random-float step-size' o- n/ d0 b9 w) m, o8 H5 N5 J
avoid-walls" S# y1 T1 }# k! E. ~
set stopped? false]0 j# N( {: C& O+ ^
[set stopped? true] ! \! t% f$ c' I$ m& D9 \( _7 u
] |
|