|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false# x9 a1 h' o8 l. u
to go5 I! H: _+ I( p! e- P5 `, G
if not any? turtles with [not stopped? ] [ stop ] * a) G9 k2 O3 G8 R% A T2 g
ask turtles with [remainder who 5 = 0] [
1 {: N2 K1 y, [5 Qset close-mates (turtles with [self != myself])with[3 w% a. U/ Z Q' W' Y0 p- A& v
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 T' N# q ?0 B" n$ _( I
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) # j. [1 w8 G) h
and remainder who 5 = 0
0 q) t. M5 M0 v- Y- Z]
' ` [1 ^$ Y5 N# M$ }ifelse any? close-mates
4 e, B R0 R8 Q2 b$ W$ l4 w8 W[ ( g( ?' R* R" {9 d
set closest-one min-one-of (close-mates with[self != myself] )[distance myself] ]* [& x- k& u- K q+ t; t
face closest-one
7 ?/ L6 A; u* L/ L: @: Zrt 180
; Y6 ^" R1 I) d% K+ gfd random-float step-size
% w6 M/ q8 N9 N8 ~7 eavoid-walls( i& e. k; U! U1 a3 P" e5 H
set stopped? false]1 c- z; f o8 [0 n
[set stopped? true]
0 \ P, X0 s) v0 X2 J] |
|