请问:+ F F |, h% K7 K# ^, Y3 q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?& U5 \( I) E. m$ ?/ `2 M
# m2 ^! B. @+ F# O+ c8 d# K8 {
! T" b1 K. w* @9 Z9 v+ [( gturtles-own [ energy ]7 E" Z5 a" U" G; y4 `
to setup
% T3 V0 ]0 k4 I$ Hclear-all* R/ d- g# x: c! t( O* H9 D
set-default-shape turtles "square"
1 h$ L0 ] ~, s+ Ccrt nutrition1 ~6 ^& o; k9 J6 m; S0 Z/ t2 _3 D* u9 R
ask turtles[1 L- P& c. T+ o
set color white1 E% Z2 r, h. Z- k
setxy random-pxcor random-pycor]+ G! q7 @' W# ]( {( v1 t
1 V E n% E) y
ask n-of microbes-initialization patches
. E u+ o* `* V/ S8 r9 G1 X, f [ set pcolor green]* e% M* t$ O% v; }0 a f
ask turtles [set energy 1]
; ~( [2 X- x/ Yend
. [5 [. ~3 `: i: S3 a, |
4 ^& `+ B" H% F: J. t6 }7 k) Oto go% p& s/ Z3 r( v# J# o6 W, x9 ?* @, T
ask turtles [set heading 90 * random 4 fd 1]. Z5 _% k6 h3 N* }5 l% o( d2 X
ask patches with [ any? turtles-here]
7 O B$ E" y+ D( O8 r [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
' |& z$ n6 s, f ask turtles [ if energy = 0 [die ]]
$ ~; U% u: u) f+ o. d end
! t5 S9 h# _1 R6 l [7 |
h0 x Z! z9 K5 l5 x( g5 p; F+ }to tt
: N& z* _9 W1 Q% k9 W* ~- Gask patches [set pcolor gray ] h7 R2 V% O- a9 ?0 a7 C1 Y! C
ask turtles [set energy energy - 1]8 Z9 v% E. L2 I& m% W, b
end- m& {5 }+ u Y" {
3 V, Z7 _' w2 |/ y5 V" j |