请问:
; }. \7 w% J7 l. c+ p随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
' U0 W& X* t) ?- b9 B' I4 ~. a. R$ r' B/ s, Z
4 r6 w8 @; ?; ]! S0 S. R
turtles-own [ energy ]
r3 a1 ` Y4 [" t6 z$ [; g2 R" eto setup6 g- q8 S- u: v8 d; i5 R9 E' @0 Z
clear-all
; x9 T2 T& P; z+ p& ?set-default-shape turtles "square"
" F3 q; w3 \$ S& [: t) hcrt nutrition+ M! b: |- N4 u* u
ask turtles[
( h1 H2 B/ ]" T: c5 \/ }. y! y9 Z( K& h set color white
& I! ^# W' M$ G) s setxy random-pxcor random-pycor]( q* w3 [ Y6 r( o8 ]6 a
# @- W: C: r/ @; f5 s+ Dask n-of microbes-initialization patches5 ^1 V4 w8 K5 T& G" J: W
[ set pcolor green]% u4 H* @9 l9 H
ask turtles [set energy 1]
; ^% Y ^- `7 kend
( A; A, V& c6 P( \$ w
" b! N1 C. }# Y0 q8 F2 Qto go p" Z2 e K: R4 u; S3 Y+ }( N
ask turtles [set heading 90 * random 4 fd 1]) s; G4 W" \2 x: {, o
ask patches with [ any? turtles-here]
0 {$ M# ^& a( O! i1 X! J [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
- r6 G* [- L1 ^% @% q ask turtles [ if energy = 0 [die ]]0 s+ a" a9 f5 k4 ^
end
% R! U! H( M J) _6 R; o
$ W5 r7 Y: y2 u) qto tt
% ~" d" u# J. \# M4 Sask patches [set pcolor gray ]6 g* O6 i" M* t) g9 B
ask turtles [set energy energy - 1]* f1 I- T% v5 o, {4 L/ v5 u- a1 O! @
end! i3 \* B1 D( e' [4 P7 G) @
L4 y! |) ^7 k
|