请问:" f) s$ W- i8 c9 ?4 H
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
7 [# I& w8 P: {/ J2 w' r& D
) w, B& T1 s% }2 Y! X1 @! F
; ^, q$ `3 g9 c; A6 _turtles-own [ energy ]
; _, `# L: ~3 v8 y3 F+ b9 E" J/ nto setup
( h! |# _' A; a+ g- yclear-all/ V; U$ ?! [, P, f" E3 i
set-default-shape turtles "square"
1 M M6 i. k- Lcrt nutrition# w& {- o1 W+ r& p3 e# f& n
ask turtles[
# Q+ F1 r9 Z% ^4 C set color white8 `; c4 R: o+ t" k; m- P
setxy random-pxcor random-pycor]2 U/ _' m% `; {: [; O
" @0 z* i# o. Y
ask n-of microbes-initialization patches x- h8 H' }6 A
[ set pcolor green]
) P' G0 j6 O; y2 Y ask turtles [set energy 1]; k0 H0 [# } Z1 r9 C( G% m
end
* h, G( q* Z. P- S
0 |" ~" ]' V0 e+ Z, O- eto go
4 g4 q# e% g9 I: y9 }7 \ ask turtles [set heading 90 * random 4 fd 1]2 Z, `% I" [3 p$ Y0 q
ask patches with [ any? turtles-here]
6 x- \. \& B, w* u5 M: z1 U- Y [ if pcolor = green and random 100 < chance-of-congregating [tt ]]3 v5 [9 I. X. ?9 }- A8 q8 N
ask turtles [ if energy = 0 [die ]]
/ N1 z) j6 s5 p: z5 T end' b; m) Z# _( J1 Q6 K" U
8 d- ]7 n1 G/ Q- P' G
to tt
% C; s4 Y) ~5 n, N0 ~/ U0 Vask patches [set pcolor gray ]
# ^9 ]& p2 E. [6 W8 J- j( |ask turtles [set energy energy - 1]! J" q8 z7 e6 T$ A- _+ ^, M
end1 {/ X* I+ a; z. j
8 F2 N( D+ g' G. {5 n# E |