|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
( R$ b3 ]3 n* K- s; @' Q- [7 bto go2 U0 J8 _. {0 r4 O
if not any? turtles with [not stopped? ] [ stop ]
2 Q8 o: _( \9 t# Dask turtles with [remainder who 5 = 0] [; B2 L0 |, o9 K+ C
set close-mates (turtles with [self != myself])with[* E S6 a, G4 {" b
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
?7 h7 J4 [, m# V) U8 Vand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 u& X7 Z" w# E7 k
and remainder who 5 = 0 2 H; J* Q8 ^( I3 W" Q9 R4 d; p# @
]
* R7 U# A$ O. p& L; P. |5 V8 s8 U$ ^2 X& Nifelse any? close-mates
3 P& W9 i) Z' m! C9 p: z+ y8 q[
5 W! W3 B* H; C! }/ X5 i: A- V- l( uset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. C4 M* X6 j6 Y3 i$ V) u
face closest-one& P# b) K; o0 U# `/ A7 m
rt 180
/ H+ ]2 p5 k6 w9 }; \( `5 `4 K$ qfd random-float step-size3 Y; P9 E& p" l2 R8 M8 y# ]2 ?
avoid-walls
" X$ z' f( z3 q- Fset stopped? false]
@0 d1 y: ?; a: u[set stopped? true]
]' A% i# ]; [9 R" G4 V* o] |
|