请问:2 P1 `! V* Y5 i
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?, ]% }: K# x5 c5 J2 @
, J+ s+ f; c9 h0 j$ l- f8 i1 x
9 u! w2 K6 E8 M2 f* Cturtles-own [ energy ]
) G |: N7 u& Oto setup
, q% K: j( {* m pclear-all" B$ n# x6 P% T z7 O' h* v. i& o) V
set-default-shape turtles "square"
: c: b4 o' _2 ]& ]3 H' w! Xcrt nutrition; f: i/ S0 i( _
ask turtles[; O# C8 J9 H7 g
set color white
. {; G# }3 I9 z: q setxy random-pxcor random-pycor]
& M6 ~( V% F2 S, {) T
2 S7 n9 L) g/ g2 O' L" F) eask n-of microbes-initialization patches
. R- [7 K* y0 d& A% s/ m& H [ set pcolor green]
1 c# v5 g" |( l0 k0 @, e ask turtles [set energy 1]# s+ ^' P {# @6 V/ `
end# e0 H H' m7 R" f7 _
6 X& o; e9 e3 d1 R! B$ l/ K, I# V. F
to go
& M0 P- ~6 d7 B! e3 a' h8 Z ask turtles [set heading 90 * random 4 fd 1]6 V; o! l% @) [: V5 P& N
ask patches with [ any? turtles-here]
% A! k& t8 V4 A8 d2 p( j8 L [ if pcolor = green and random 100 < chance-of-congregating [tt ]]' m7 I9 ?0 f4 A! a" z) ?+ _
ask turtles [ if energy = 0 [die ]]
$ U( s4 ]$ K* I end( I+ ]8 I2 S) Z( a! f% W
' c% D5 l8 x" l( Q+ B: ]# }
to tt) h% Q$ a G7 f# N/ B- }. ?
ask patches [set pcolor gray ]
4 X X5 B% l5 o" c( ?ask turtles [set energy energy - 1]: ?- b5 L% ]+ a! C5 |
end2 l0 E; q6 r# c4 Z# p8 G! o
# u! v- v; F# j7 [
|