请问: f& h. J1 P! j/ h! |. A
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
( K A A' ]. l7 Y3 `5 {5 }
/ u. Z8 {- g+ j: c2 w3 F' r" C * h+ `* ^: M8 L& Q/ e$ D
turtles-own [ energy ]
0 x2 O4 }' C, |4 e+ d/ fto setup
* z5 Z6 x* \& ^$ `# J: t, gclear-all
2 z5 O2 A( ]& \! ^- Y! @. {$ Vset-default-shape turtles "square"
( F1 y# h: b7 Bcrt nutrition
% P- e! {) B! o( T% }7 i9 Mask turtles[( e2 ]5 P& m! T! g8 i9 i
set color white
- h+ m& _0 l# }) |- \( C setxy random-pxcor random-pycor]
5 P" Y0 a2 L1 | 1 k; n7 h/ J! V E# b ~/ a4 w/ ?
ask n-of microbes-initialization patches
+ J' Y+ ]* M" ~8 Q/ M: Y( r2 `. u, M [ set pcolor green]. z! N( E) L2 U) h! F, ~9 w
ask turtles [set energy 1]7 j R/ s1 ?! U1 G3 W" G
end
8 x1 c4 i! W7 E8 x- _7 t& v* g4 I; ~8 O
to go2 s+ {& P+ Z) Q- a; h, j- }
ask turtles [set heading 90 * random 4 fd 1]4 G( S$ k2 E6 _/ z4 H7 Q
ask patches with [ any? turtles-here]
) B7 [/ J) Z: s9 e [ if pcolor = green and random 100 < chance-of-congregating [tt ]]9 S; r! T, l6 I8 j/ g& _! M$ z
ask turtles [ if energy = 0 [die ]]0 V( ~: }8 z% A1 `# Q
end! r* j7 S5 i3 p' [! p8 T* X
0 \. {2 R2 q3 L. q* V8 Y
to tt
3 B! j* W' N) e. i9 H+ dask patches [set pcolor gray ]2 o9 E3 T+ B; L2 o/ [
ask turtles [set energy energy - 1]
0 s- L8 c' D, ]% o: d; D( vend1 v, I8 y* s6 i) I. f% r
+ B( u+ p; T( d6 g1 _ |