请问:# ~% a6 D$ n0 ?! d+ ~8 b! H
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?5 r% y/ _ X) ~! L
0 e2 I7 _. P. c" j' d+ {! h: J
4 J& c/ H: v; gturtles-own [ energy ]
& g6 X" s) k+ V3 g! K# ato setup
" K( D4 X3 V" _# bclear-all
4 j1 J6 n( _3 i1 sset-default-shape turtles "square"' |+ w& o9 U6 }6 o/ V9 ~6 R" |
crt nutrition4 k, l0 f$ `# m3 ]
ask turtles[7 g& I! C: L5 E# c \3 g
set color white
, c& D3 w! C" ~; a( @5 ~ setxy random-pxcor random-pycor]
9 D: q' z+ Z B
0 C& d/ W- h& d8 j; S1 [, {+ gask n-of microbes-initialization patches
5 o8 ~1 B: @1 m6 _% q [ set pcolor green]
! U+ u0 ]1 Y. } b* N5 ?' |& t* g ask turtles [set energy 1]4 m; r+ B+ m$ `! _
end( j2 G0 C4 B% P9 J* Z
$ f3 x# r, w. d% U) F1 [0 @6 u, rto go
0 y9 s# m! U, t# Y' v% ~. D ask turtles [set heading 90 * random 4 fd 1]
; L: g L9 ]1 G0 ~" S9 Q- I ask patches with [ any? turtles-here]7 c- @+ A9 x; h% p9 W
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]1 u! F8 V! h8 r, F s1 L
ask turtles [ if energy = 0 [die ]]
& y, P) U: X$ F& z% t/ s end, ~) z1 z* I" O8 L
1 F2 c% [& ~" qto tt
1 c( w- H% ~$ h: l' V( dask patches [set pcolor gray ]% f$ r& e) s- I( j
ask turtles [set energy energy - 1], b$ N6 W& ?* _# x% A" r" A
end3 x |+ x" q" x$ r2 j) G) P
% [, ]* T5 J/ P- W2 R3 M
|