|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ y4 x* _( B4 q! Z8 w
to go+ v6 o5 K" `' R3 A, |8 H H
if not any? turtles with [not stopped? ] [ stop ]
7 ^6 }% C5 U1 R( X, w* rask turtles with [remainder who 5 = 0] [
- O; s: \/ v' U* Hset close-mates (turtles with [self != myself])with[
8 j' A3 A7 ?, O" j. ?6 J& N) i( t(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 D# c3 R7 w3 k% Jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. u0 S% C) S+ S) R# V) A! aand remainder who 5 = 0 3 g6 U n) Q# o
] $ D/ M2 I7 U7 ~% |( d4 A; A
ifelse any? close-mates
9 v- M3 N/ s) ]$ [. ^, s; n[ 5 V/ F+ L' Z0 D+ `
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]4 l8 s" z( v- `- q O
face closest-one1 Z0 I0 p/ {0 S. C
rt 180
~$ \5 ~' q5 i$ Cfd random-float step-size
! u# V( G; s/ uavoid-walls
$ g" x* |5 E$ H2 B& gset stopped? false]5 w; L* m4 K% Y6 B5 D
[set stopped? true] 5 j9 E4 E) R6 Z$ J' j
] |
|