请问:
, r+ {, ]+ k5 l! R! ] k# |随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?8 Z- @: }$ X) Z% f. f# |
. f* u/ X% h+ c3 p$ v
. ~5 K- s5 ]3 I( P" V
turtles-own [ energy ]
- d6 E' z' L/ G: Q; Qto setup
) H4 k" u/ B4 u7 m7 z- c( z1 g1 y7 qclear-all- G1 p% E2 v5 L' k* E, }6 g
set-default-shape turtles "square"
( f; _: a' n; ?& ~3 w5 B" Scrt nutrition% @; x* b ~5 T" d7 Y6 N8 q
ask turtles[' u* G% ^3 y q7 _' T2 `! s$ _
set color white$ x$ c( C3 f3 A- P4 P0 Q
setxy random-pxcor random-pycor]
5 ~7 z; Y& P3 j
2 s9 J$ s0 ^ m+ f* I: J, u2 Uask n-of microbes-initialization patches
9 w+ u! h+ Q# e+ Z' z% ^4 ` [ set pcolor green]" I7 i1 h) I0 n: H
ask turtles [set energy 1]
: C1 y& J1 k/ J Q3 nend
2 W7 G' j V, V/ D0 x
$ N; d) r* n3 h3 ~, kto go
5 R/ q; D! R1 _; ~: p8 M j* E) y ask turtles [set heading 90 * random 4 fd 1]
0 t Q: N, S0 j ask patches with [ any? turtles-here]7 F2 u5 o O+ S( U2 i* f
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
0 s7 M u' O5 H% Q) T. R' J" b ask turtles [ if energy = 0 [die ]]8 A) z8 \" J, p4 h
end
; l( a r4 |% G+ J3 E
$ F* v& Q: o* h' T4 N' H& D- E5 Bto tt
+ q# Z9 S! m4 Zask patches [set pcolor gray ]+ F5 w/ ?4 f- ]/ \
ask turtles [set energy energy - 1]
9 `5 K. q* G) m+ B) _5 wend% c; \" K5 _7 u1 ^, |4 r
0 h) J' l7 a# f; {, h0 d/ V |