请问:
$ ]* a+ I8 o5 d1 v随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?* ]" T: u' r+ F6 x) B) P
L% e/ y o, r0 S' ?; t ( M4 p: U3 Z! @' ]
turtles-own [ energy ]+ m6 Z5 r; E# K8 |! O
to setup
$ l7 {+ y0 X/ I4 f' o+ `5 o6 Rclear-all; R' o; _2 R4 z
set-default-shape turtles "square"
. M- d9 |' d5 M' Z1 Dcrt nutrition
$ C$ P5 R+ H) H8 j0 {+ }* vask turtles[0 \+ X4 ~+ {2 u1 I2 R; }$ m2 l
set color white/ M, J( w% g$ i" j+ r
setxy random-pxcor random-pycor]
( e: J S' M5 T: p7 e' \" b9 [
{2 o' K6 \! _, ]- {* Yask n-of microbes-initialization patches0 R& S( }% n& v, r
[ set pcolor green]% z+ h+ V- n# z
ask turtles [set energy 1]5 W- u8 b6 S! L& ]$ Q8 C
end' p! }0 n5 K. i! ]& Y
; F& C6 J- [8 f) t8 c6 `' @5 Xto go
+ h$ C% s, Q5 a% `+ R ask turtles [set heading 90 * random 4 fd 1]
' M* R. j9 V( F( V3 y# w3 \$ @& r ask patches with [ any? turtles-here]
c i0 q; }8 c3 M% m5 _8 z% h7 A+ T [ if pcolor = green and random 100 < chance-of-congregating [tt ]]* [$ k( w) A1 x" W, Q [( k I! R
ask turtles [ if energy = 0 [die ]]) l, j0 M2 w; b
end
' ^+ V3 W' j3 s0 o
7 ^2 R' n/ l; `$ B3 R8 _: ~to tt
2 q5 j: v' O# I8 xask patches [set pcolor gray ]. ~; w, p6 z+ P6 S+ u. J$ t: @
ask turtles [set energy energy - 1]
* j- \; J. R; K- Zend
4 j+ d* v3 n3 ~# R, n0 O& ~; O* \3 a3 I- |
|