请问:, T7 q7 K) R& |2 L% r6 T3 @
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
3 C" g, `/ w. B7 g& r5 w: ^
- j; U' h3 l3 r0 y9 ?2 @9 a
! g% A; k/ I$ |: n }1 _$ }turtles-own [ energy ]
# m( c, z9 @) V/ \( yto setup
, u2 D# Q! a( l/ Dclear-all0 J0 L& n& s' S6 m9 Y+ i3 `; I
set-default-shape turtles "square"
" P9 x, }, b6 M$ ^4 z$ Dcrt nutrition: r3 p( u! W- O: ^% g
ask turtles[" C/ e* Y7 X- m5 U- t
set color white
7 B: ~3 W3 s, ?# f9 h setxy random-pxcor random-pycor]
2 q9 v2 _0 ]( \$ w- b- o1 ~8 H" D : T0 A9 J2 l# |3 C! v
ask n-of microbes-initialization patches$ Z0 k$ `" B5 t2 X& T- h1 N
[ set pcolor green]* m; U+ i/ a. H5 n
ask turtles [set energy 1], H, m: T8 U; _. R8 h7 m1 b' b" m
end
/ d6 R5 U' y$ ?+ G H5 [4 [3 P2 M# r! K) C0 @1 W* L6 G' I
to go/ o1 n: |) [, e
ask turtles [set heading 90 * random 4 fd 1]
& M1 ` U3 F. k) j: a& E) g ask patches with [ any? turtles-here]
+ X3 s8 c$ A0 e, _8 K [ if pcolor = green and random 100 < chance-of-congregating [tt ]]' U8 N& M% {4 S4 E4 j7 b: {
ask turtles [ if energy = 0 [die ]]
& L) ]' S- ?# q6 }" z8 Q end
9 n. N. |% i" \( u+ c; I2 }9 n/ x7 U+ i! l% {
to tt8 U# A8 \4 a8 m) a1 O* y( N/ S
ask patches [set pcolor gray ]" A" n7 {. g7 w- ?( @+ ^0 W
ask turtles [set energy energy - 1]
9 ?3 O$ o; U" P+ [, H2 \end4 R! T. K" r& V6 [
% }! |8 F) P( ~ |