|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' O7 |! Z8 r7 F, ]% fto go
2 I- T. W" U0 B5 ]' Sif not any? turtles with [not stopped? ] [ stop ]
8 w4 D/ M& y2 A$ Cask turtles with [remainder who 5 = 0] [
- G0 o N6 Y, T2 D+ x% y$ wset close-mates (turtles with [self != myself])with[
$ O$ Y' q. C1 E(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( y3 \, x# K: X7 d' b4 q% X
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) : ~! {8 `. _% ]: z- H% ^
and remainder who 5 = 0 . g& G. \# {" A6 h! o: C9 l8 M
]
, I% S/ S$ @! u; J0 h: c' [% V: ?, kifelse any? close-mates
' a9 s4 g: c9 {' Z0 a9 i% A[ 3 B, ^0 G& G5 s
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 G6 Y) Z6 M" M+ @6 ]' g t8 }7 O, {face closest-one6 [0 o. O) a4 `
rt 180- @6 V2 d* B1 r% ?
fd random-float step-size& u, H$ ^3 n- v9 m4 b; S! h
avoid-walls
; o% m8 u! @0 B ]6 @set stopped? false]" e3 ^& D* ~" D' C9 Z, J* J
[set stopped? true]
; s4 ]- ]: w: `) E. v] |
|