请问:
9 A8 H" v1 U6 w$ h' r) [随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?- ~4 w0 H2 i/ _6 ?
1 z) W5 X7 e9 e, r( o8 {' s
0 R6 e2 M- n6 Z
turtles-own [ energy ]+ [6 s8 ?0 V5 [
to setup9 c! u$ ?( x. C2 r6 {) }5 p- \
clear-all _# X& B* P$ c. j7 v/ t& h
set-default-shape turtles "square"
8 ]) }3 L7 V8 K+ W7 kcrt nutrition8 O% Q* ]6 y1 \1 L+ p' W$ d0 E
ask turtles[* D" r% r) z( J* F2 G% ~" @
set color white
/ X, Q, |$ A+ I i- { setxy random-pxcor random-pycor]
`) a: a! J* w' D( N, D $ B+ Y' y% z$ ^5 q' ^( c8 |
ask n-of microbes-initialization patches( i% U6 C; @3 x/ p% P+ z
[ set pcolor green]
# @) k2 N7 ?- u0 x" T. _ ask turtles [set energy 1]
( x7 f8 U5 M& A2 `1 s& Send
$ J8 i6 X% S; R5 g; o; x; y8 Z: M2 b- \: Y
to go* N/ z% s% f: V# x1 w
ask turtles [set heading 90 * random 4 fd 1]
( J$ d9 s8 D2 T( M$ [ B* ~! @ ask patches with [ any? turtles-here]. c o3 B% [9 U# X* \
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
A' B+ R4 M+ C" n7 {6 Z) b. E% M ask turtles [ if energy = 0 [die ]]& T( d( M: t. l
end4 z( ^, L4 f) W! d5 Z
- v, G w8 i8 b; O% [' y- R
to tt
+ Q& V$ y! }8 g# u* ]ask patches [set pcolor gray ]8 B5 o2 R! K+ o8 B' i! ^+ V. u
ask turtles [set energy energy - 1]3 K L3 P) }# @" E' ~
end4 c1 u1 |: S( A$ C1 ]
0 [8 p. L; B& g# Y5 _
|