请问:
* L9 u6 b3 J1 C随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 U7 a+ i* W! d+ u3 K' t
1 f' d) D4 y- a2 ~- h" ~+ ^4 z1 c6 U 0 `) B) n R2 H) R4 w6 _1 P1 u
turtles-own [ energy ]
. { {: c j2 A7 c6 h2 r+ hto setup/ f6 P x; i- ~' U! s9 g$ J2 u
clear-all
4 q" Y- H* a1 r+ ^* nset-default-shape turtles "square"
& Y, P# C3 \- D7 A) _. B, @6 s9 |crt nutrition ]+ Y, @0 N$ X
ask turtles[
+ M7 g/ u0 s& i/ q; C, U9 |. a set color white
$ U8 v+ N7 m' @ R6 U) ^ setxy random-pxcor random-pycor]# U7 d: h/ Y& d3 u; \5 G! K
% w$ _ l) U+ Z: D* I) d
ask n-of microbes-initialization patches. H" Y( w8 E7 u
[ set pcolor green]
! }0 y3 }1 O* r, a( r ask turtles [set energy 1]! g9 C& E# u+ Z/ [/ Q
end
3 p+ v9 r; g3 X- r# ~& B) H& T7 k& R# t! |+ a! g! `
to go
. t7 O; t8 y) o* M4 s ask turtles [set heading 90 * random 4 fd 1]
1 E8 [% H" P* L ask patches with [ any? turtles-here]( L& ^% Y) Z7 g+ t* `1 \6 u
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
) l/ g; Y/ `( t; p7 x- _0 [ ask turtles [ if energy = 0 [die ]]
8 _1 ~3 V) } l+ F) X2 V end
# U& c- P' q/ K% M$ s& B
+ ^- g3 t3 u/ Q$ s1 s+ Xto tt
3 z0 b" }9 w |( x( iask patches [set pcolor gray ]/ u, V6 H) T: Q6 C q0 S2 F
ask turtles [set energy energy - 1]6 E; F3 K3 ~' p% i, x# Q" ^
end
% ]) {+ B, A; `! C: y" C
6 w4 e y' n& I: | o7 ~1 A |