请问:
9 Y" x) q. x8 C& M; J随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?7 @* E7 e ^7 z
3 Y( q. u. J3 b+ d; V! o- v# [
4 z0 N& w* R# [* w9 F! cturtles-own [ energy ]
E% j3 k* s& Wto setup
0 i& x* u0 f4 kclear-all* i& w! x7 x' t" [1 ~3 I
set-default-shape turtles "square"
! ~$ d# D- q% p' i0 }5 Dcrt nutrition. E% ]/ u) `( d/ y
ask turtles[, ~2 }+ R v# N$ t- r
set color white5 j& a- A: q& O. g
setxy random-pxcor random-pycor]
3 W' y2 w, |4 X 1 U4 T1 a3 z2 \. C7 m! s
ask n-of microbes-initialization patches/ b! B. [0 t5 o
[ set pcolor green]
2 S) K' F+ x6 w ask turtles [set energy 1]3 E1 c" L" a3 v/ b+ K: ?6 ^, D& {+ ]
end
/ D: C2 M9 Y# \8 [( p. x ^
6 Y. v! o* v" b6 }( ato go
" v1 z9 y7 g+ Q0 o5 t ask turtles [set heading 90 * random 4 fd 1]& \0 F# c5 B; n" X: A8 n
ask patches with [ any? turtles-here]* o- y" J# D4 i5 a6 y
[ if pcolor = green and random 100 < chance-of-congregating [tt ]], V/ {6 n1 z% d% U7 Y5 n
ask turtles [ if energy = 0 [die ]]( D+ x1 i! X& K0 t0 j6 g
end
1 Z) h$ G6 q7 A7 \5 h# q
* w5 f9 x. C ]4 Dto tt
0 h3 ^$ q: P- X/ B" _ask patches [set pcolor gray ]
3 I, w+ { r, |# `ask turtles [set energy energy - 1]+ M* H% f; N4 B# o% F( u
end
- @( n1 Z* @# d' N+ r3 L; s. q" e) i% ]( d1 a6 K
|