|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ K0 Q- v5 V: D9 M
to go
5 g/ a8 Z4 v+ i& D' q- xif not any? turtles with [not stopped? ] [ stop ] 5 s- l, E2 s% W/ X4 x. j! p
ask turtles with [remainder who 5 = 0] [
# h' I |, r/ m, mset close-mates (turtles with [self != myself])with[* Z# D. ]3 l$ o2 B$ h- G8 y
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) % _" w1 T; Z' E! b* {, Z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 @3 u+ a7 q( V' x e; V8 d
and remainder who 5 = 0 t2 ]' A: A$ a6 S! H
] . u& S2 t8 I8 |; r
ifelse any? close-mates 6 e; P' r& c/ z0 T8 [
[ ' }7 Z$ J$ G. z9 {+ [
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]; d" K; A% H* j/ C, ?
face closest-one% n7 T$ f' v, X( i% S
rt 1800 b, k( S7 ]* X& _5 ~
fd random-float step-size M! z Y7 T M% C) Y" c$ O5 `
avoid-walls% {; b: O% U; e' }
set stopped? false]. {4 W7 N! r5 r: u
[set stopped? true]
1 _5 o: Y7 \) d# B, e] |
|