请问:/ t8 V5 M O6 f, h8 c( y
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" Z, e+ j @1 r% \4 i
* x- Z/ j2 ]4 |
6 z: M: e! l1 i4 r, {
turtles-own [ energy ]
! W' T, k" d, t: Z9 P( s2 Hto setup
- p# p, ]' ~, N) n8 e: iclear-all; a- q. Z: `! x& B) P, p9 a! o. L" g
set-default-shape turtles "square"5 U) W) X; K: p/ C* i: T o
crt nutrition% D' V& C* a a5 x
ask turtles[; C& E- V* ?7 ]0 }
set color white" }5 F; Y8 r: n" X
setxy random-pxcor random-pycor]
- F1 c7 |8 x- X1 q; H
/ @' O! t$ b/ T7 @2 mask n-of microbes-initialization patches
8 v' R3 i9 x5 \: E' g9 i [ set pcolor green]$ a$ |0 v3 _0 f" `. m" U. q
ask turtles [set energy 1]% v, Z9 \: v# q
end. r& U5 e4 R+ q
9 Q+ Q- E( |9 [2 w
to go* U2 Z* c" y1 _( s7 D* { B C% K
ask turtles [set heading 90 * random 4 fd 1]0 S" e9 I, m$ u8 s$ A1 Z X
ask patches with [ any? turtles-here]. m' O6 u+ v' r
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% f& N$ ?4 f4 J! H ask turtles [ if energy = 0 [die ]]$ ]& ?; s0 v4 W- h) r
end* M* @; M1 [) j3 g0 L
6 b: t1 ^$ e! cto tt
+ l* r; h5 ]! T/ x0 u g$ uask patches [set pcolor gray ]
* K8 q/ h) }% D8 rask turtles [set energy energy - 1]: ]6 b Y1 R) |! a
end
7 Z& d9 h r0 ^6 e# ?9 k8 P* m0 B" I4 U% c b. j
|