请问:
( C2 h+ k1 V# C/ W# g2 D: u' u随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?4 i5 I: S9 v7 C" k, t0 ?1 L- D h
/ S: X' S5 G, X
6 H: e2 G1 U( M4 sturtles-own [ energy ]
& q% e* F- \- Z& lto setup
G8 {' S# o& q/ Iclear-all
: Z# l" e. p0 t) A; ?- Dset-default-shape turtles "square"0 ?" Q( c' K- g/ M
crt nutrition$ z8 q$ p4 y. l8 |/ m |+ `
ask turtles[7 b! M: W, O! T% E8 B! T* r
set color white1 |/ }! j1 e$ y& q
setxy random-pxcor random-pycor]
% G! [' [4 T, B3 C 1 j% O @! I/ m0 P8 }8 U
ask n-of microbes-initialization patches9 D+ \2 g B, U; \, W
[ set pcolor green]& A( [, @2 k2 y4 e5 {+ y
ask turtles [set energy 1]% o8 n+ I+ W( A. a/ M$ |* \
end
& x# h) D+ T! t4 [
$ q/ g& l7 A' O N: \/ o- |1 r; O7 m8 Oto go4 ~+ C4 {# l$ m9 t- r% v
ask turtles [set heading 90 * random 4 fd 1]* S) X3 w( X& U. \+ T
ask patches with [ any? turtles-here]% q8 M6 g/ Y$ ]7 c
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
2 W0 h9 Z% z( B1 ~ ask turtles [ if energy = 0 [die ]]: B6 Q& K( k& Z' C0 W- R
end$ j1 @. q4 H2 T+ G
# D- j$ W7 b( `) M# h9 ?: fto tt# c$ u. }9 f3 L( ? A8 M% s. w0 ?. |
ask patches [set pcolor gray ]) F' ^* F7 Y% _6 P; h& y
ask turtles [set energy energy - 1]6 c2 Y' `! [& M) |" ^' v
end
. G0 X) H, F3 f' a. t$ ~0 I$ l! S/ H) q: {8 `* t
|