请问:$ ^6 d& C/ d" i
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% `% W) Q7 _ M5 e' M, c |$ p; h0 f& P; r2 _
- a7 {5 A: l* B" ?! @
turtles-own [ energy ]' p0 U7 W5 G8 C2 ~
to setup; {" Q& A1 [6 R5 h9 V7 o
clear-all0 v+ E% j* n2 f% q6 s* Y8 G' Z
set-default-shape turtles "square"
2 g" V: ]0 ]# ucrt nutrition( _6 n# ~7 e1 H( q3 [% [2 r& P
ask turtles[) ]9 d) [' }1 Q" {
set color white$ M9 z3 M5 y$ [4 j
setxy random-pxcor random-pycor]; t+ d( k2 M+ f6 ~2 M% P
0 ~# p# G2 ]4 n- u6 o7 s3 ]
ask n-of microbes-initialization patches) ]2 ^4 X8 Y/ _. I
[ set pcolor green]# n( l& m9 y! a. \8 U; m
ask turtles [set energy 1]
) H! f8 ?5 h. ^( H" y' M d( Pend! h3 A( c ?+ Z
$ `3 `. H* q/ ?* |# b
to go
g* R g2 s. _$ Q" B ask turtles [set heading 90 * random 4 fd 1]0 F6 f V' x: n" e& D- Q+ ?
ask patches with [ any? turtles-here]
: V8 K3 q# R C$ v. y# l& R [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
* o# ]: ?) i# R" o% G ask turtles [ if energy = 0 [die ]]
* C K8 R. c+ a end
, a7 ^6 T, `, u0 A u/ h3 m* l) @8 v- @5 U, h" d
to tt/ K8 m6 b% ]. _0 ^- X
ask patches [set pcolor gray ]) y, i4 O# z' b8 ~" x. R- B
ask turtles [set energy energy - 1]
$ @" w" m. Q; J. ^end' `. u5 ?" [: X$ k
0 D% ]6 W4 `. a# f* o |