请问:& o2 A+ S8 x: c' g% _
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
u& j+ A5 }% b6 Y# f9 `# E% t
8 d: g0 Z' }$ ~% J ; ~# q0 x+ q. y6 ~
turtles-own [ energy ]
3 Q( \ T" f7 g/ m# {' Fto setup0 w! b. {5 s* z3 m0 y2 a8 Y
clear-all
% D$ o7 _& L. |! d$ e0 k3 U/ sset-default-shape turtles "square"' _& G" J" m" D; s
crt nutrition
- l% U" X1 h/ v' s: A6 l" Mask turtles[. e: r0 z( B! t0 `" v4 J
set color white
x$ [. E9 v, ~) u/ y4 y setxy random-pxcor random-pycor]- v4 ]4 M6 N% a5 F9 |7 j7 F. X3 X' F
: v, \, c1 D& v2 ?) _' Hask n-of microbes-initialization patches
# X0 Y, D9 Q) [" r5 [ B( V [ set pcolor green]
: D: O. R( h. E2 B2 h" l' z2 | ask turtles [set energy 1]" Z( O- G+ b1 O, S
end
4 ]* `) E: B% r& Z4 t
; x- W3 I1 w. o( `* }0 `* Rto go
' Z/ u# K7 ^& D+ S5 c ask turtles [set heading 90 * random 4 fd 1]- A4 `# u! A, m' Q3 u; h, \
ask patches with [ any? turtles-here]
- V6 q. g( @+ O% k9 [ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]6 T; a, H) Z" `1 A) f
ask turtles [ if energy = 0 [die ]]9 a! z) O1 X3 p2 s3 m G
end
+ O) Z2 [, P1 o" m; H n' C9 P8 a: p- g
to tt
) q# T" X* ^6 f$ b6 ~% X) Mask patches [set pcolor gray ]5 r4 \8 [5 r4 H
ask turtles [set energy energy - 1]% k; \; q( D" C1 R
end
2 V7 m3 G: ]4 [* `' T7 I
0 a! h+ S, C0 g |