请问:' M; g& [, Z9 i* L) ^3 z; |- F* x
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
) H7 X$ j* J$ [! N" ~( u# e% P; l. A
6 e: z3 y8 l! y: z8 w( H# ? 1 D( r& d( U* t6 r) B/ g& t8 g
turtles-own [ energy ]
$ H, D$ e& V$ X9 O1 `2 Fto setup
* G! Z% j& T' cclear-all
6 G' n+ @ m. V6 W) Rset-default-shape turtles "square". G( V$ Q& c) |* ~9 O
crt nutrition
1 a& j6 n N. j/ i/ [ask turtles[
7 X+ f7 V9 e/ E' E) [ set color white
! W+ p; P8 y% b+ h' Q) O setxy random-pxcor random-pycor]
6 J& b* K9 q* r8 _0 N, J
- d2 B5 }% o" g1 Pask n-of microbes-initialization patches
0 A8 p) k* K* ~1 ~ [ set pcolor green]
+ c, h9 P# J( a ask turtles [set energy 1]6 |% L: c Z. _& } z- R& `. L
end: W0 {# e6 `6 U* t& \* g
4 t) J; s: e- r! E) t0 t- i
to go- A3 B: q4 i" d7 k
ask turtles [set heading 90 * random 4 fd 1]
j Y l% {# [1 w8 Y! q& E8 `" ^ ask patches with [ any? turtles-here]
& U x1 N1 {7 r% s/ B: D; X [ if pcolor = green and random 100 < chance-of-congregating [tt ]]2 o7 V: {2 y [5 B- r& f
ask turtles [ if energy = 0 [die ]]! u+ x0 Z4 {$ Q6 o7 A
end; j R! K, l9 w! o$ J; l# I7 Y
* {. Y- E# M8 R& ?4 u# }9 |
to tt# S5 I) B$ D% g6 Q5 f
ask patches [set pcolor gray ]% o$ g! a+ O9 s" ]
ask turtles [set energy energy - 1], I* q( t8 V W! J9 C
end
8 s/ B& C# z3 n" v, U% @9 a
5 A5 Z7 ?6 T- `4 T5 ]; v5 D3 S |