请问:4 o, q* r1 ?% G- @! o
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?5 V* d6 N9 \8 N- i d+ e
( I* u5 }) ~5 y 6 _/ s g1 ^1 e; q8 B
turtles-own [ energy ]4 W6 N( n& F# H3 C" V. a& e
to setup/ B$ T1 p" u' a6 }0 ~
clear-all0 |: e2 u7 ~8 v+ P; y, @8 O
set-default-shape turtles "square", n: T) ?- M5 ^) Y. e! X$ f G
crt nutrition X% ]) Z$ l G3 j, P
ask turtles[% J# |; i% c# c7 o
set color white8 L- h3 c5 Z9 J# z0 Q( N3 q2 A( G
setxy random-pxcor random-pycor]
* X" c p6 V+ i' { ?
s% ?6 w+ [4 n# c& e9 h; \ask n-of microbes-initialization patches: ]8 `, o+ U# \' F- K( p/ o
[ set pcolor green]% R X- P, m6 Z& Z6 l0 B- i# `
ask turtles [set energy 1]% U( w* R5 ^/ X. s& b" {: Z: o, s' k. y
end. P6 z- h# u; [9 a$ _9 F5 E
1 T5 s: y/ V1 D
to go. u% l1 ]0 }5 J4 i$ h1 P
ask turtles [set heading 90 * random 4 fd 1]
) u, ~5 L5 q& d! m% W c6 w* V ask patches with [ any? turtles-here]/ w" F) Z _5 G$ V9 F1 ^1 U. T
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
1 r. l# d& a1 q0 k) R ask turtles [ if energy = 0 [die ]]5 ?% S. u1 t0 B9 w5 @
end
5 X( O. Y2 w; |4 z! N4 z* S# {1 D1 N
to tt
5 P4 z2 [, S; | x% Lask patches [set pcolor gray ]- L& o( M$ n8 s$ P
ask turtles [set energy energy - 1]" c) B5 G+ t3 d& H0 S5 U
end$ g# ~8 \2 `9 g- c) t
1 c/ w3 @2 N, C4 @" g8 d
|