|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: S' k; j+ W6 S9 i1 I& _
to go4 s3 ]* l: L6 W( d0 p7 M, A
if not any? turtles with [not stopped? ] [ stop ]
- ]+ \4 S' A" U% [( g3 @' Bask turtles with [remainder who 5 = 0] [
7 O! \2 f" s5 ^ o9 m+ q- gset close-mates (turtles with [self != myself])with[0 ]' z' r* Y7 D6 a! r
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) _2 Y0 Z% E" B' Y* ~
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
; s# P# q& ]9 g: ?$ Qand remainder who 5 = 0
$ ]7 v! b! B z# l" U* W9 g]
& q2 P3 m6 M, S# V4 c+ @ifelse any? close-mates * @1 Q8 ]/ B. A0 K& n* p
[
" c* @2 v8 c: L5 F' kset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) Z/ y- _) F2 a% r6 Z3 Dface closest-one) `6 O N% c2 s4 I% N8 h
rt 180
+ d3 @. X) m, c7 `9 C. ~& B9 ifd random-float step-size: S" a* I0 Y! J1 g$ d+ e! G
avoid-walls
4 O1 F8 G% N; y6 pset stopped? false]
/ V5 c; s% h4 s) V4 k x: v$ W[set stopped? true] : d2 Y/ p9 O X
] |
|