请问:
3 z0 n0 X# |! K随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
: M6 L( [/ {( \+ c
* v% ?! z4 l5 N. k
* L* E% n/ [9 B H# O6 C1 tturtles-own [ energy ]
1 o( U: V1 i. W, Eto setup9 b: q9 S/ ~- {) M/ z
clear-all
& e; q4 }( s, `. A5 z A2 @2 ?set-default-shape turtles "square"
" n: ^. h4 z0 ^5 Kcrt nutrition2 b4 R0 o' C) I! ?" j2 r
ask turtles[
0 S; k/ N7 z: u( u. ]& T set color white
. e8 I$ q- l6 P8 n setxy random-pxcor random-pycor]* d5 ~! }1 l' P* f2 M7 p% g
/ j1 _, d3 a8 }0 k$ [
ask n-of microbes-initialization patches: ?: O9 i/ g! G+ J
[ set pcolor green]# a, I" U3 Q3 T* `
ask turtles [set energy 1]
# F8 ], _6 J4 B$ j5 ^1 |end
+ {2 ^1 B+ z% m* @0 m% V
. L0 g# D9 N {% Jto go7 H1 J, H; S* n
ask turtles [set heading 90 * random 4 fd 1]6 B# U- {* a( [' U Z7 D" o/ e
ask patches with [ any? turtles-here]! |& i2 ~- p3 c6 K) v0 g
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]3 G" p+ V3 c$ z6 C# e
ask turtles [ if energy = 0 [die ]]
/ ^: R) W1 W4 F4 @1 D- M1 @9 ~; p end0 \, ~0 G, H5 z8 Y* ^5 _( K
9 Y" P. s( Q) {3 l$ z
to tt
9 r# f' l* }* x4 j) jask patches [set pcolor gray ]
4 g% S- l$ u! g2 N }0 Sask turtles [set energy energy - 1]+ m& x" D, s8 z% y" V0 m7 n/ d
end
# X& F% d& J- E' g
* c9 |/ l" z y5 \+ W% y |