|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false0 R' Q% n8 R& D3 S2 `
to go- W3 ?' j3 y/ _2 }! m
if not any? turtles with [not stopped? ] [ stop ] " H& _5 `' W9 \0 d
ask turtles with [remainder who 5 = 0] [ W- A/ S& G! B6 o3 p7 b
set close-mates (turtles with [self != myself])with[
1 A, b, N/ R1 _% B# r(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) , d: O+ R, r8 z1 v$ F3 _
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 a/ Y6 q; ]+ `9 m1 i
and remainder who 5 = 0 8 ^, y. ^7 ~7 F+ ~' p; X) Q
]
0 N' t. l# k- J; g9 }& yifelse any? close-mates
4 V* x; H3 E+ Q1 m! H2 N+ g[
0 M7 R' F. _0 J; A5 Cset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
5 |% N% x+ ?' H* X5 `/ o( ]! Mface closest-one6 H% J" d) c) \" j- O$ a9 t) A
rt 180# Z" E# v1 e% P m3 E1 T
fd random-float step-size. E! I# W8 q+ w5 g
avoid-walls
) N# e% I& i9 Eset stopped? false]! u! p5 y/ b# S5 z/ c( `
[set stopped? true]
* z$ `8 ?! a0 E; H3 o! Q+ j" c# t. U] |
|