请问:
+ M# a3 d' d" [) v随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?% N8 a3 o ?6 _6 p& J
& S1 ^" G" T" U
/ J, ]" B' ]! V0 p/ p
turtles-own [ energy ]
9 x& \& [; D2 O9 {" B5 sto setup
% {: f- q/ s% l; g$ D7 S+ @clear-all& C* x: I6 d! g5 N! s( i
set-default-shape turtles "square"
+ Y1 D: f( G5 o8 x8 V- {/ I; Dcrt nutrition" d& k! S& K0 T. i$ ^1 k
ask turtles[7 D; Q7 w; t$ R# Z! M% m
set color white8 P/ h! t/ l6 f, d
setxy random-pxcor random-pycor]
- {' G# t; _, P' t8 Z( @
/ {& r* K7 f; I. D7 T5 P+ w, f4 d# u0 `ask n-of microbes-initialization patches
7 W: D: Q' v1 s% y* r$ {* l [ set pcolor green]
, D9 `4 b& n& Y ask turtles [set energy 1]
2 m/ S, q0 G/ ? Wend2 q/ I! R8 ^ @; h* }
4 G( t5 z+ s, `/ z5 @
to go
" k" z5 r6 a* D0 @9 n! W ask turtles [set heading 90 * random 4 fd 1]0 d8 v; Q6 J* e* T4 K0 q: x/ Y6 M
ask patches with [ any? turtles-here]
1 M! M( w( ?8 o; n4 l/ x [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
, f3 @2 B5 l4 O8 ?4 N ask turtles [ if energy = 0 [die ]]5 W+ V& X3 A$ k, S" _ s
end
O% l/ j# C0 d$ Q/ m+ D, \ u0 e0 X* z: Q( I3 m+ m
to tt
5 o# ~* F3 J \ s' |+ Oask patches [set pcolor gray ]
/ |( z( j( t5 K/ a4 a: M. gask turtles [set energy energy - 1]; n2 u- H& z' D" Q- y7 v) t- G0 b
end
1 L3 T1 Z5 L/ ]" G# T) r+ T" X% }
# a. C$ a, C- D8 A( y4 N |