|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" [" {+ D2 w+ M' G% W. O: b Bto go
2 o& X: N0 }* q9 M: Y! [3 O T4 J7 Gif not any? turtles with [not stopped? ] [ stop ]
4 e2 ~; b' Q5 ]# {4 r3 Mask turtles with [remainder who 5 = 0] [
. X' y. x8 F: Q' l9 R+ a/ w- Xset close-mates (turtles with [self != myself])with[
6 k+ @4 Q; R2 b: d(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ; a# \! y7 p" R) Z. q* t
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 V! u6 Z3 m! s# g3 D/ K9 Z2 p! ]and remainder who 5 = 0 0 w" l! B% o+ A7 w! T; A
] 9 Y9 ~7 b$ U/ N! t$ v' K2 ~5 d
ifelse any? close-mates
" R/ w! C1 {# ], v+ [[
; m- A$ F, [/ a- Qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]) O* Q1 f+ `, s: ^' ?% d' o C
face closest-one" O! K) U' N( S1 h3 N
rt 180
' {, G6 K; F1 A. {9 Lfd random-float step-size
+ s" [* |4 l; o. ^$ navoid-walls1 Y3 o$ T' g3 q+ x4 u4 t) w
set stopped? false]
1 W7 x6 s% B2 @* t9 l[set stopped? true]
5 A. r) h5 u0 P" M4 T5 H( |2 w, l] |
|