请问:: ^5 ^3 P# u7 i+ \: r& G
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
# v' b8 A' s! z7 H: _/ I0 `
8 N l5 b" Y8 T) l
9 ?1 l4 b: \. P$ Hturtles-own [ energy ]5 |& n+ n3 [, @+ H* `
to setup
" Y4 a0 V* b" B, V$ j" Wclear-all& x. l" z. W' x- B
set-default-shape turtles "square"1 A/ A! y/ B: }
crt nutrition" Y) C# K9 U$ x# c/ ^
ask turtles[
: v% O1 U# {7 v) j# V3 e2 x/ P6 | set color white( a2 G% g- z- F. b
setxy random-pxcor random-pycor]
) j/ E5 E5 U/ {
6 G7 Z- { F6 g' \ask n-of microbes-initialization patches
Y) Q9 j0 Q2 V [ set pcolor green]
3 C9 M2 k) k5 W8 l ask turtles [set energy 1]! O3 Y- ~8 ~7 S. V* ]+ g5 H
end! }+ A9 a& S, h. K! s% |
1 m2 ?% K% v6 }9 }
to go
" {# ~4 X* X" \7 }& s7 d" N ask turtles [set heading 90 * random 4 fd 1]
4 w2 O8 Y$ o$ h; T w& ?+ l ask patches with [ any? turtles-here]
2 @4 `4 O$ @ _3 _! D [ if pcolor = green and random 100 < chance-of-congregating [tt ]]: @8 B) k( q6 \. X! ?8 [# D1 }
ask turtles [ if energy = 0 [die ]]1 @6 Y6 ^+ G' N
end7 c) n) \; @" O7 W% ]3 H
t5 H- v3 |! E H9 Rto tt
+ U P" P* K& c6 i# Iask patches [set pcolor gray ]1 j# L; `! Y \5 d1 C( t1 N& [, P* d
ask turtles [set energy energy - 1] s6 ~# |0 m8 U1 C, R- w# J: p+ d
end" f( ]% S% r. H6 r
7 J* k- y. a0 K. k8 O8 } |