请问:# e8 D/ W) [3 R' f7 ~+ q- [! n
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
3 H! J% H, u8 B, a3 x4 j& y- `' v* E* e+ {# R
8 H+ X, b# ~% b7 C" H
turtles-own [ energy ]# X& G: R$ n" B! N c
to setup" x3 R; g) b" [8 h9 J9 R
clear-all
. S# e, |$ l) cset-default-shape turtles "square"
4 y) F7 V* l% T. Z `/ S- qcrt nutrition
' ~! ` J/ s/ Vask turtles[
5 N9 ^& T! ^ ^/ [: ] set color white2 ]1 f( V* ?$ a( @. L2 |: j" M
setxy random-pxcor random-pycor]
" {( [+ z/ ]6 u+ _! U8 F % N4 }- u; y" b" I, \
ask n-of microbes-initialization patches6 @" u, S4 `; O* o, Q. O9 P
[ set pcolor green]
2 _+ Q2 |) b) a" ?. x4 a6 j5 s ask turtles [set energy 1]
- [0 ?0 t* I4 A2 ?2 |7 Hend
, G0 P5 ` A2 f3 K# w
: \/ Q0 p5 t6 R& y0 Nto go5 {! u/ `3 v- h$ K% E, j1 r
ask turtles [set heading 90 * random 4 fd 1]2 J& D* Z% T+ b* z$ L
ask patches with [ any? turtles-here]
. i' f+ ]+ w; W: m# _ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]$ ]! a, Q3 `6 G) i) f* Z8 T* J
ask turtles [ if energy = 0 [die ]]
4 M; W9 p7 l; t+ J! i9 ~/ ~ E end
3 E! W1 C) P$ D
% B9 O5 ^* M4 D, m5 Uto tt
* `7 A" V; O; I, o! vask patches [set pcolor gray ]7 k. i# T9 O& X* c( _' Y4 v1 ]
ask turtles [set energy energy - 1]: J, s! `9 y/ L& S5 d- `
end
^" d. i# X6 i$ n/ c
5 e: A8 @' V7 l: p6 f$ ?/ l |