请问:
8 W2 U7 @7 w% Q% z' G- s* V随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?( V8 U+ \% ]$ o% `
: Y$ A! R+ T) z- `
$ f) h6 o' l o( b5 c
turtles-own [ energy ]! p% v7 ^' X$ k& Y
to setup
; B+ D& R6 C1 q' a! Tclear-all: B7 K" _9 S1 X! o$ V( F$ Q/ M+ u
set-default-shape turtles "square"* X) `3 ], L2 l1 Q! K
crt nutrition
, g0 X' p7 o/ L lask turtles[
, a4 e# J% F: K set color white& M9 Q: {$ Y9 A' h- `
setxy random-pxcor random-pycor]- _8 Y; ~. Z9 `9 @; U
3 \7 m }( A: P4 K E3 S0 q) j
ask n-of microbes-initialization patches8 X8 ^1 s# l7 T3 a, i( c: o' H
[ set pcolor green]
! }2 y" z% [' q2 ~4 B n" P ask turtles [set energy 1]; z3 \2 ~, V* H) m5 |5 ~
end5 K" k+ U% @0 r: _5 D2 G0 B
6 ^+ z9 M7 s0 W [
to go
. ~2 `8 G1 M* s. J, v6 }+ F ask turtles [set heading 90 * random 4 fd 1]
: J$ X" w. z* X9 G. H% j6 w ask patches with [ any? turtles-here]! _5 ?% ?+ q& h" @7 i
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]* p; y ]. t. x
ask turtles [ if energy = 0 [die ]]
5 g% y: Y+ t. a- I end
; T+ w) z/ g9 ]0 ]# c3 r. g* H/ _! y" |+ {7 v
to tt
+ b; s: t5 _; q) {* F" nask patches [set pcolor gray ]
! z1 s# e" o/ V9 [9 W; F* Jask turtles [set energy energy - 1]
, C) }$ s& ^2 R Q( [end
- e) `4 _% @# K/ f0 ?1 ^9 _+ I. w& @' E
5 F( y9 h' O n0 B& m: v |