请问:" `3 G: r8 Y0 I2 [* z" ?5 T
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?* q4 R9 h7 o" y' t
, J/ Z6 z; `. l2 `
9 f2 U' W$ o1 V* Y* fturtles-own [ energy ]
( l! p8 d1 h( q3 L9 x" {* zto setup1 @+ m; [8 e/ [2 o7 q
clear-all$ b7 c; X% i' ^* `
set-default-shape turtles "square"/ {# f Q. ^; t/ Z
crt nutrition
5 ]" ^3 d: P( Vask turtles[7 c- m6 q: j4 a, O
set color white# Z5 e- M2 C! r( Z1 }, |9 |
setxy random-pxcor random-pycor]& H9 A& D' h$ t g9 U: Q& V
- r2 W5 N, g4 \* q0 _ask n-of microbes-initialization patches6 j( q* B1 ~, S* t, K9 L# O
[ set pcolor green]2 R2 l- n1 }/ [1 y
ask turtles [set energy 1]
5 h1 T+ s2 c2 E5 {+ t; r: Q5 |end
/ ?* Q, P8 X# t/ g$ o& j* j3 o4 z9 K( J9 N- E1 w3 {3 G$ k& m& Z
to go
8 f, P; k6 {# ^' q8 @ ask turtles [set heading 90 * random 4 fd 1]) x6 N( O: ]8 @
ask patches with [ any? turtles-here]5 @( q5 V7 k; c0 O, o% {
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]0 ?! H1 U0 C5 [5 J: A6 D
ask turtles [ if energy = 0 [die ]]
# J' y7 b/ O5 q. a end
/ P, W6 X+ y5 d8 J+ }1 h% D7 t" z" q9 g; d' W' Q8 O
to tt) `/ U; y/ e2 M3 K- B) G
ask patches [set pcolor gray ]
* V7 y2 k4 x' s. d3 u2 aask turtles [set energy energy - 1]
, W. w: b5 c6 R6 Y) ], o+ V' X1 Dend
/ m2 m5 U4 u* K! u: X, d0 ^* G
|