|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
; C Y2 ?" z$ o9 v N& n5 }to go
4 \% x9 {9 r# C/ Tif not any? turtles with [not stopped? ] [ stop ]
' k- |8 ?! A9 X1 n* h" gask turtles with [remainder who 5 = 0] [
6 \ o- M6 x- s- f- w0 W( Gset close-mates (turtles with [self != myself])with[" {5 s6 J* T9 _9 L
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& \0 ?5 C( f: ]3 ~* C/ [" m% g. o* Jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ G1 e0 [' I; j4 |# W
and remainder who 5 = 0
1 J, O2 w& r8 R# V" L( R0 B] ; p; E' J" |. P |. X, L/ f- M
ifelse any? close-mates
( [7 k/ F& a6 f3 G[
- [; H. r) z& R" Lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]& t# g* ]& \ _5 U
face closest-one
- p8 P% y) t6 |2 ~2 irt 180
+ L0 S# P4 N! [; ~- b. B$ bfd random-float step-size
" s$ h6 }8 g3 \; o8 J. zavoid-walls4 N/ d9 X( y( i* D8 [0 r' Q1 d% f
set stopped? false]5 `3 m7 m6 q9 i4 H2 i, W& ]
[set stopped? true]
1 a/ l w% @5 w( W] |
|