请问:7 `9 M& u) f& c* q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
) G! V3 b( Y1 W* r2 k% F& x
+ r1 S: _- _/ I; s/ x1 ]' M8 S$ R' A
; x- u7 c9 T( x* J/ Nturtles-own [ energy ]
* |! }5 {; a; N7 Vto setup9 c9 I, S' ]- i5 m/ c! D5 L
clear-all+ Z; e+ r: Q+ t3 E
set-default-shape turtles "square". w" A. R5 P; J' {+ }. _3 P9 S
crt nutrition
5 u3 P$ e2 L* ?1 |9 U2 yask turtles[+ A1 P$ |6 ?6 r* ?9 ^3 ]2 s+ w2 _- M1 I
set color white
) T6 q' C( w/ A b2 _% {+ s8 E% @ setxy random-pxcor random-pycor]5 V, z. ]9 q9 j/ I
% D2 j$ R7 I" q
ask n-of microbes-initialization patches: [5 t% m; c9 F
[ set pcolor green]0 Q1 x7 V8 a P+ B! g7 @) x% f
ask turtles [set energy 1]
. W: M2 m# Y7 Qend
, @4 X6 f/ @3 W. @' K: d' Y' ?+ J9 h1 {9 C/ M7 l
to go
, n& l7 Z' I' L, g7 {! t ask turtles [set heading 90 * random 4 fd 1]- o" \$ z" k( G
ask patches with [ any? turtles-here]
5 I7 I! J+ P; _: o: z [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
( `3 H* ^7 a9 q/ ?# l8 a" ~/ t% e) B ask turtles [ if energy = 0 [die ]]0 I' X6 Z& Q! U% H4 Y3 i! C6 }
end
5 j- h( C! G4 ^) _! j# z$ ?, ?4 s. a S; D' x
to tt
# j4 q: p- H" d. z1 Kask patches [set pcolor gray ]
0 {6 |2 P1 f6 G) o) q8 R; gask turtles [set energy energy - 1]
& ]# ]' K# s1 c4 M6 c. E) d* jend$ Z, Y% W+ i3 B% s7 O* N& c8 v' l+ f
& P8 P6 W0 c# |* l* h
|