|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: h9 d! [5 F0 O3 ]' L! M8 Q; y' P- u
to go
, N- r' t5 T/ k2 Hif not any? turtles with [not stopped? ] [ stop ]
. h1 i6 U, c9 n6 y* J- f& Vask turtles with [remainder who 5 = 0] [1 s, p! `* [& c
set close-mates (turtles with [self != myself])with[
% E( D/ X: o) W. A/ N, \' X1 {(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ |$ B: `4 R8 Cand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! I+ @/ s) m, `2 Dand remainder who 5 = 0
1 x2 z* o9 f- e7 w]
' y2 |+ g' z% v- qifelse any? close-mates - J# p6 N4 t# G$ L$ L& U4 Q
[
6 ~. `0 a) K. r+ r5 L1 @0 s4 K' \set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& z' G% k+ j# q* V A# ?: U3 ?0 X/ lface closest-one
; S% h: @0 b9 J- _, K$ a, jrt 180* U4 m: F5 e& F8 H
fd random-float step-size: D( g/ R# P0 B: P1 d* h
avoid-walls
1 u- U/ M( B) |0 X, Fset stopped? false]
/ b; t- R$ s( u" _: Z5 w; K) O# @[set stopped? true]
3 \/ z5 K# e! e4 E- R4 t] |
|