|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 R$ [3 \ `/ p! O; h% xto go+ p, w K- e! g# v5 s7 x
if not any? turtles with [not stopped? ] [ stop ]
4 s9 ?) L+ O0 U- ^' B2 N- hask turtles with [remainder who 5 = 0] [5 o. K6 D1 b1 T( {5 R, }" q
set close-mates (turtles with [self != myself])with[) S4 T3 x1 U* k. ^; c: W) Z
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 O* p8 B5 m: T9 G# i
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % b: u8 r; f. G' U% l- I, L
and remainder who 5 = 0
. o# D% P$ k8 B" B0 n]
3 M8 F* d5 Z9 H1 C/ w1 O- }) difelse any? close-mates ' h" ^! H2 u/ z" S' S
[ - s4 `: c/ S4 ^. E8 }
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 R) C) R, X7 T, lface closest-one6 [! `( Q% P6 e( P. u( }1 v0 N
rt 180
3 \ P- Z& W* Zfd random-float step-size2 M' T/ `. D+ u/ Y( d) M+ i
avoid-walls2 z# p- K% H" S; m! D& C/ i2 G
set stopped? false]7 |7 j% @. Z; j2 N
[set stopped? true] 0 d# a/ u! @5 a+ ?
] |
|