请问:
; [# g8 N% O" z7 O6 u" R随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?: Q5 k3 C2 Q7 J' O D/ {# x1 @ t# T
+ v4 y; r4 H3 d' A* j, }; {9 M) F
9 f0 P4 J( Z" ]' D- V `6 |turtles-own [ energy ], W0 d0 r9 a. m$ k" B
to setup! R/ \/ Q* k/ X/ r+ _) ~
clear-all
+ F7 J% v; ~ ~2 W x) tset-default-shape turtles "square"$ `4 r9 q! Y2 T4 H9 G
crt nutrition; i) p0 ~- |5 G. V* I7 I1 K' d+ p
ask turtles[& V6 J2 |5 s& S4 c+ ]
set color white
# d, _ s q t- B setxy random-pxcor random-pycor]2 e0 S3 u; s; d9 P, F
# W- {' M7 G% P9 N1 }5 T2 L
ask n-of microbes-initialization patches& [) w" d! o9 e" T) b
[ set pcolor green]
6 H1 B- P+ f: Y" ?+ Z9 \ ask turtles [set energy 1]
$ J6 M4 I7 l: @* Rend
1 G7 e2 ?* G) m* S+ i3 f& {: W' r4 b9 z
to go. ^8 {3 {0 o' D4 m3 v# H
ask turtles [set heading 90 * random 4 fd 1]
: o& g" W: B+ N, ^) e- | ask patches with [ any? turtles-here]
- q7 J R# J5 f4 H% ] [ if pcolor = green and random 100 < chance-of-congregating [tt ]]3 }2 c0 r. p* h P: k% l6 |
ask turtles [ if energy = 0 [die ]]
" Z9 }9 K8 D9 t4 l' N5 V. Y" a end
' Z5 [1 U& ~+ \( B8 R- P" S
5 d3 @" B$ `! K7 rto tt
4 ~5 H& T3 r1 \/ L! ?+ m( s1 Sask patches [set pcolor gray ]# {- l7 x/ E6 Z% F6 ?( j1 P) ^: b! k
ask turtles [set energy energy - 1]
0 K- C0 \ g6 ^ W+ u% Vend
* T$ S; @; k7 y+ Y7 o$ u
/ u. W+ _: j8 O, G |