请问:
( D' B+ V1 r, z# Q3 n' O随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
|9 ~* Z8 w5 n3 t* M) h/ V- `- u% \, V. h2 g$ ^3 t& s
3 {% [' O" [; n2 g' j
turtles-own [ energy ]
) Y5 s4 V# a) |& x( h' @2 ~+ Wto setup% e3 U& t' q' K- n
clear-all" w8 z% t8 x3 C: i! I
set-default-shape turtles "square"/ H( ~& _4 I( n j4 s
crt nutrition
! B- s$ T- Y& a% Rask turtles[
0 n: C# J% a1 S6 y set color white
7 J5 h) u, s$ J1 w- U2 D6 }& Z, s setxy random-pxcor random-pycor]: C! g: m: f* y- p$ k( D1 f$ h& L
$ f$ Y! R+ r: U; Vask n-of microbes-initialization patches
0 m% Q, b& ~% X% v5 W! t [ set pcolor green]$ ~% u! B0 k- b$ G8 _
ask turtles [set energy 1]
, g- Y+ h5 \# N" Eend
B7 Z% ]: \( P& Z0 F; G7 v% x$ Y
0 k/ e8 r9 k5 H3 B& Fto go: r" C( X* ?8 O( S1 [. }" q
ask turtles [set heading 90 * random 4 fd 1]7 y0 V* R/ @+ f0 m- ]
ask patches with [ any? turtles-here]# r q9 S& H) t
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]: l% X$ s( h4 s3 C$ s0 B& E' d5 s
ask turtles [ if energy = 0 [die ]]
* ?( }: `" `0 O' ]' Z end# n9 F6 T5 Q3 n. L' r/ }% [
9 A' k5 y- D3 \" e Nto tt
f/ L' o7 }* Dask patches [set pcolor gray ]! R/ L" E6 ?0 x0 b
ask turtles [set energy energy - 1]$ D( [7 c$ ^7 ^. W
end& h: {- w1 \. o4 T
: S, {' X, U9 c0 S' z. \ |