请问:& h3 I# h& [4 ^' E
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
1 @2 s" m, ?: o; b5 ], j' d# |" h" E( t8 I; |9 m* v8 x
g8 V/ t! y7 ^, Sturtles-own [ energy ]
7 `. _, f# p& W9 w( Dto setup1 c; q. v7 T9 B+ `% F O* ~5 @! b
clear-all
4 h/ }) j# Y4 z ^" l& T0 Lset-default-shape turtles "square"" R) C( P& ]9 r$ ~* v) `0 U
crt nutrition, j ^, f9 {1 P
ask turtles[
* B/ B! S: |) x- T' X set color white5 o# f/ P" x8 x- L- {1 a
setxy random-pxcor random-pycor]
8 l$ N9 c4 m0 C1 O4 G+ m / v) S) u2 v+ x- c. Z( [
ask n-of microbes-initialization patches1 f7 b0 A7 _5 l& b0 N- q
[ set pcolor green]/ q5 c, V, w% | H- }- [- u: I
ask turtles [set energy 1]
( y! A% \* s5 Gend
2 f( T& {+ M- c- u+ R# \" C% b' o6 ]$ @( c! z' Q2 t% G/ M8 @$ C+ o
to go( k1 K/ g( Q# L2 Z# d- ], s
ask turtles [set heading 90 * random 4 fd 1]5 M3 Z- v9 D7 Y6 x6 C; _& J& _# j1 Q
ask patches with [ any? turtles-here]6 `; P, T* k" r0 [+ b
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
; _8 X. Y4 U; ^- W, ?3 u. b ask turtles [ if energy = 0 [die ]]! N7 ]/ Y& v# _! [3 d
end* D: T4 H/ p- c# B* f+ i
/ @ W7 g# M( ~4 y6 j& Z
to tt
# X* A1 o7 y1 Y! W; Z8 fask patches [set pcolor gray ]) z' r8 s% ^1 v
ask turtles [set energy energy - 1]3 y c; P) ^0 {- ~6 z' K
end j- p( w+ C! z
7 O/ [6 o/ D1 h3 K" z: b
|