请问:
& G8 b! y% O( I, d, O1 @* E. ~+ f随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?( S* n1 e4 c! |7 v3 ^/ O* u# I: `
. }1 ^( Y9 y: F% U- P4 P & C, A- N1 P { j9 J
turtles-own [ energy ]# B2 B' ^7 O% o0 K6 _
to setup) J9 N5 j' M, p& {. K/ B
clear-all% x7 \8 r: F ]2 J% y
set-default-shape turtles "square"" J- u% u0 A. r
crt nutrition
1 a0 [- o( a# C& b) D! _/ L, @ask turtles[- k; G. a6 c8 }8 v! e
set color white' [/ ?0 A7 Z: A2 V; f# l
setxy random-pxcor random-pycor]
- k* _# p" l- `" x$ S. N + p7 y- K* C( O W8 T- H
ask n-of microbes-initialization patches, H; s3 `5 H$ i) t! W7 B
[ set pcolor green]
# [6 H5 M; W: l% j ask turtles [set energy 1]
( A. e$ ~4 ~. J9 ]5 f: t* @end
% y# i2 b4 w2 n+ V9 R; I, I
+ S3 v6 @: A1 P1 h/ i6 G$ o4 pto go
; }4 }6 B# s2 b2 b3 }0 r ask turtles [set heading 90 * random 4 fd 1]
S! ^& M8 f, \; c) N ask patches with [ any? turtles-here]) j3 a6 {+ [* s" A
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]8 m6 e, d, Z( s% \1 q$ U
ask turtles [ if energy = 0 [die ]]3 Y" a8 r' L" x9 i7 C) K2 i
end
d. _; i1 z, j% b7 P
4 h K3 d n2 q% b9 vto tt
' Q: p+ g y: }6 `0 ]- bask patches [set pcolor gray ]! a8 u" p1 D/ D d" f/ A; ?
ask turtles [set energy energy - 1]
( V' _9 E6 B" H4 @: Bend
9 O! \1 n, _/ i6 N% Y% o
* J, }; D; O' N& j1 y# L: ^ |