请问:$ r+ H4 |$ q+ ?
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ A2 v7 [6 H8 c. y3 O
5 f$ |, L' O# n, r5 b
w! n0 G6 C# X" h% ?' hturtles-own [ energy ]! H- `# |- S3 S
to setup
; {) k) W" g9 iclear-all. R" Q5 D% s/ U( L' S/ c! m0 m
set-default-shape turtles "square"8 F- w5 j0 ]2 k
crt nutrition, I8 y- e e7 S3 J* ?% y3 ?
ask turtles[
( D: Z0 ?% j4 `* s" S+ l set color white
# k/ H [. A( _2 @, P setxy random-pxcor random-pycor]' B+ C" U3 j, F/ B |8 X
$ R/ f f3 c( U1 m$ d5 m3 J4 x
ask n-of microbes-initialization patches! @( S2 l0 U2 w! \/ R; o, j
[ set pcolor green]- H; [ T1 o& ^2 ?5 P: O2 S
ask turtles [set energy 1]8 L9 h! L, e8 |# P
end0 Z; s( x3 _" C* v- a/ D
" Z( u* N |- q+ fto go* i$ ]' D! X4 |( K/ h! ~. C$ O
ask turtles [set heading 90 * random 4 fd 1]6 f. x4 N) p$ s" h; o7 E
ask patches with [ any? turtles-here]
* g, {) L2 e0 Z3 u [ if pcolor = green and random 100 < chance-of-congregating [tt ]]) L8 A0 w3 ]4 y! p( t
ask turtles [ if energy = 0 [die ]]8 }# E$ r, B" T
end
- g# d/ e, I1 |* A# Z1 K. z3 a( I' r- N1 Z
to tt; O! N2 H; z# W; z( O7 Y- S% J
ask patches [set pcolor gray ]4 \3 ~+ J4 [8 ~* a7 j8 B
ask turtles [set energy energy - 1]
) k1 v6 A. k1 `4 Q6 Xend
# i H& q- Y( h: x6 k |& I1 p! @4 H8 j- H
|