请问:% j+ R S1 _, M0 i0 C
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
, p& Y% A: a7 Z! ^1 {, b0 S" }% B
# h6 ]5 s$ n/ r+ Y; D7 j0 C; @4 m
turtles-own [ energy ]' L' ~' n2 [! B$ |% Q0 K
to setup! W: ?" I; B- x: C( i# q& {
clear-all
: @/ R% w$ e0 a6 K. Wset-default-shape turtles "square"2 V5 M0 E. a; C; ]4 ]0 Y0 S
crt nutrition( `5 A1 N" \2 T# A$ b6 S
ask turtles[
$ h3 b. r, g K# K% C set color white, x9 p) d# e# k+ L# B
setxy random-pxcor random-pycor]4 I6 e8 S, Q+ Y7 B- O1 @' ^. I
! j" Z7 D/ Q, O8 L2 eask n-of microbes-initialization patches S+ y0 Y* ?% s8 S+ k- H3 _
[ set pcolor green]
/ j2 [# Q6 z u+ U! K0 R ask turtles [set energy 1]
, E* x* n/ U' c! Send }( y/ E4 f; S. l
+ Q: J# @$ _3 }6 |" c: T
to go
! @7 L o$ A. I$ k ask turtles [set heading 90 * random 4 fd 1]6 F& x' _' l& }( y. @7 F
ask patches with [ any? turtles-here]
/ ?$ H: `3 ]# Q0 K) ?* E& e% _ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]0 ~" n3 L7 V% e. T6 h& l
ask turtles [ if energy = 0 [die ]]& o3 E K3 }6 ~5 u
end. r4 B7 m" |0 ]; ?9 e
h0 C) D& d" ~ E: Vto tt3 |5 N9 t, X; L
ask patches [set pcolor gray ]
: t" Z$ p; s1 s! L1 L' P2 K8 E1 [4 D- hask turtles [set energy energy - 1]6 b* \# s0 D! g) _" r- I
end, [, c! P3 F; }( L
1 i7 y# M7 t! C: k* M: ^
|