|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# @- A. K* {5 d: b# Q+ D1 `6 eto go3 ]3 }8 z; E: O5 l" |0 T. e
if not any? turtles with [not stopped? ] [ stop ]
- D# u( B8 g# n! R8 oask turtles with [remainder who 5 = 0] [) n! o0 I/ k4 U8 q/ r3 y
set close-mates (turtles with [self != myself])with[
' Z, Y; W C5 G/ P( G# L$ K(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) % X9 U2 b! I6 w( {
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ( t; n7 B0 t% D
and remainder who 5 = 0
. U* h/ Y* C0 c# T. T5 e] " n9 Y2 k0 }, F. Q: x
ifelse any? close-mates / b( k# O0 L y. Z. q; e
[ " ^- H7 [4 u9 O% o: k: u) R
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
; w, Z; w( u- j p7 ?- d9 B' Fface closest-one
. T* J- w& u Y# `rt 180
u/ D& q7 _5 |fd random-float step-size
$ A" d7 Z4 f" ? c% W& w/ d X& Zavoid-walls+ s$ u, N& E' Y7 P; ~) G# t
set stopped? false]3 L, |) u- Z7 W# C7 n
[set stopped? true]
! W7 L; R9 U' q) G: |- p] |
|