|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& T% A6 B- d3 ~/ Vto go
! u# X! A& Z# \3 Aif not any? turtles with [not stopped? ] [ stop ] $ u4 e4 {8 S u7 X& s
ask turtles with [remainder who 5 = 0] [& @- f( O5 `3 R6 u, n* O
set close-mates (turtles with [self != myself])with[" z* C# a' \' ^' j) T, O3 S, Q
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) $ t$ M& E/ ]2 v/ a
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
* ^8 P: a+ w! |6 Z# z& A, [( Gand remainder who 5 = 0
. W9 a* H! N5 {4 T& Y] 4 f. a9 f. P9 M
ifelse any? close-mates
/ `! ^( a! @2 ^0 E) _[ + C" y! K, K6 j5 k
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) r4 j1 L; k F) Gface closest-one
# ~) p9 p0 O7 `" p4 B# b' Hrt 1808 i' g) T) `5 t9 }: L
fd random-float step-size! k k/ @# K' b" z/ o7 Y( h: _3 F
avoid-walls
! J# Z' p! E: T- m1 Kset stopped? false]
3 {7 R2 H7 A! d; i, r* e8 s[set stopped? true]
) A7 r* P& n8 ?] |
|