请问:
& F4 g" p# v/ z7 |1 ?随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?2 B$ C5 \ O+ {8 l( a7 ]
3 A$ u* c- R w: f! f& Q5 ~2 X; A, l9 f
! v @( i4 t' f+ W- t1 V
turtles-own [ energy ]
, k/ |, }" l- y8 T) xto setup
! y$ z* j4 Q' q ^ i2 f3 b& Yclear-all0 J0 ^3 C! d7 W9 y P) r& A: z
set-default-shape turtles "square"
! l; i" _ I4 V7 Icrt nutrition
& p% _7 P: F B" y" R/ Qask turtles[
& t; s" K& _; ` set color white+ Y5 P+ U& f" u% {- G9 F
setxy random-pxcor random-pycor]
" k3 o M$ y0 [7 `! {+ R5 j ; ?! z+ Y7 B0 Y; ^: j" I
ask n-of microbes-initialization patches7 y( z5 Y* _4 L! X o; [ G
[ set pcolor green], ` W+ q4 w# N) }* f+ O
ask turtles [set energy 1]
% ~! |6 B- s' s! fend
# q+ Z* m1 o2 ]! Y
5 f A" X$ J7 n: O5 dto go
( D* J$ c2 ?5 \& ^1 C ?7 Y ask turtles [set heading 90 * random 4 fd 1]
, y' z" g. _ ^4 Y/ e) S1 d ask patches with [ any? turtles-here]
& U/ J% ~# q, K( j2 Q [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
7 c- w7 I6 }. }+ `( R" M ask turtles [ if energy = 0 [die ]]! n; d) ?5 E/ j' ~+ D; D
end
! s% x B2 V7 [$ Z, D# U" l' s* P$ y# i2 `& C
to tt% C' E# o% l Q4 J. H: I
ask patches [set pcolor gray ]
B4 Q: H# g$ j2 _* Y7 yask turtles [set energy energy - 1]4 a# @+ l* R" w( a# u! G% a) \
end9 y2 [) k% J6 T- A! `8 k1 D) {
( N# I) H- m9 h1 F% `+ F/ r N8 u
|