请问:2 ?1 e& K# X0 U1 q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
; @# m+ o& i$ [- l% N% `* X7 h# y! |' w+ ~. l) u
/ r: T9 k9 c# w& U
turtles-own [ energy ]) X0 Y5 _" O" l' I1 S
to setup
7 s8 C& G9 r% Z" a% U5 X# |& V. Wclear-all
@: E+ R- g# I* ^& Y2 v1 S5 Vset-default-shape turtles "square"5 g+ r. r2 o: l" u$ T
crt nutrition2 G: }, I# p0 e! g" d6 f# x
ask turtles[
. P( J7 ]2 {" Y& Z set color white: V( F, g+ E$ g( Q
setxy random-pxcor random-pycor]
5 B& j3 p4 A/ x' Z ) C* p; b7 P( S: n0 r
ask n-of microbes-initialization patches
- e* s; F9 e( f [ set pcolor green]
; E- U [8 [5 }, U% B8 U ask turtles [set energy 1]
! T6 B% s3 }6 jend
2 Z% @: w; U! c7 R9 g3 D0 c! g1 P3 B# y6 T- n4 M( q4 f
to go# ~. U: e+ a0 b+ ?) g( A
ask turtles [set heading 90 * random 4 fd 1]
& A" t! w6 A# T9 \" g ask patches with [ any? turtles-here]
7 a c5 \# a+ Q5 q" p [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
0 m1 I8 [7 p% P; m: s ask turtles [ if energy = 0 [die ]]3 Q$ u8 ]# T6 @3 g
end
! G1 z5 X+ V! V! I: e" h C4 A% f
* p8 S7 I1 W, [( E7 [: r# fto tt1 I" y( h9 H! P6 [9 @/ n6 A
ask patches [set pcolor gray ]
- W! g* v$ [2 s4 S) }- hask turtles [set energy energy - 1]3 v$ `4 k. T# v! k2 t- M
end) x7 o; z6 O8 a1 o. M: D
5 F+ ~. I1 s6 P$ s+ R q# b
|