请问:1 l8 {! T J: d/ F% n+ ^
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ ?- f7 n9 q5 H
7 ^# w1 ?4 \# P3 i1 Y! i% H+ f
1 k7 j6 i3 g& X, U" I! Aturtles-own [ energy ]- k7 _$ [+ G$ ^& Z( B4 Y7 v
to setup
5 B+ `( A0 I8 E% \0 L cclear-all
: U. v2 @9 w! @set-default-shape turtles "square"! M2 z7 K7 O# H. D4 Z" R. R8 N! G$ \
crt nutrition
7 M% C4 [9 Z5 t# qask turtles[
& V, Y1 R1 R. E" v6 C4 ? set color white8 D7 Y. s$ n' x3 e* o# W, q) m$ ?
setxy random-pxcor random-pycor]+ w* G. l, N- ~. Y" q& V6 \
% g& x- e# k+ n- }" M
ask n-of microbes-initialization patches5 ^* f8 B2 s) `9 L/ f3 W: W' b* L
[ set pcolor green]2 N+ \: t2 \1 E- d& B
ask turtles [set energy 1]9 x$ _; F4 G0 d0 O
end
& v* ~7 P7 C, m9 {
; A: B x; U5 Z0 \* J, k2 I. w6 O* Bto go
+ }% `- S9 s8 `; X% ?6 g- U# a ask turtles [set heading 90 * random 4 fd 1]
* v# k9 f8 f# T* I) R ask patches with [ any? turtles-here]9 M* \4 V7 A+ I
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
. @) w3 ?+ }& i$ r2 a ask turtles [ if energy = 0 [die ]]
8 a0 A6 L7 g! u" x8 y& n1 S; p end& M- f$ n B# N. l
# }- X, T! T9 a
to tt7 O0 F4 X' m( t, E; ^6 n1 X& u9 y
ask patches [set pcolor gray ]) p/ k7 R5 Z9 R. j- M
ask turtles [set energy energy - 1]
& W P3 m9 _) c Q Aend5 [; ^1 O% F8 n" Y* n7 x+ }
% X y W4 }* Y) i2 e |