请问:
- Q; y) t( F3 v" ^, r8 P随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
$ m7 m- x7 g" i, f1 o1 G. c
: k! s" o1 H; J% ?% y- X7 W
) Q* Z9 [. ~; h7 u3 N' F# Aturtles-own [ energy ]
# g" y' D+ G1 x/ v4 lto setup) ^: Y* w! c! V+ [5 i& N
clear-all
# ]) ^9 J; v3 c0 A# i8 k; Z- Z9 b* z3 l: {set-default-shape turtles "square"
1 K$ E) d/ k# U* _( f+ R. fcrt nutrition
- u: k5 z& ^/ i9 K5 d" U% A& b* aask turtles[
* G" s4 A" y B/ i6 Z8 R/ e# A set color white
/ a; j+ R. _ v; }# R- L setxy random-pxcor random-pycor]( L g7 m( G- `. O" v( Z$ l& @+ C
5 Q7 d' B5 s J, i! F8 Sask n-of microbes-initialization patches& j- H- G5 w& [& Y* |5 F9 a
[ set pcolor green]+ T2 P5 k5 [, b) T- h3 C1 f
ask turtles [set energy 1]
# h4 Q- K) K; s4 C0 ^end: f/ Y; {5 i$ H" L& @# a! E$ R" C* K
0 h4 Q( g+ G8 h, E( ?0 t# |' u) a# Y
to go
9 [( f8 h0 |- n* @ ask turtles [set heading 90 * random 4 fd 1]
; e3 E' l( E* l ask patches with [ any? turtles-here], l6 x% n8 ^4 f$ [$ h8 w
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
E4 U4 R, L6 ^# y5 i' c# M0 l6 a$ z ask turtles [ if energy = 0 [die ]]1 {$ D8 n* V1 Y! N7 l
end
/ ^ v% ^: x/ Y9 k% ?. v: [. I% q2 V
to tt0 z F! b' t/ \" Z7 e
ask patches [set pcolor gray ]% \: B9 l9 @# {* O, M O' l( ~
ask turtles [set energy energy - 1]
S6 M) h: J t, send
9 N7 E/ R0 \3 V2 v5 `2 t, @. x% o+ ~- x% W# Y ?$ A5 n
|