请问:
* Z# [4 F: P2 G! L7 i随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 G+ n7 i% C3 u/ ]8 i B. @7 B2 }3 J/ p4 Z, @/ D
$ q) c$ {" B& \! m( Y2 Bturtles-own [ energy ]/ L; t- V/ I6 O* v, t
to setup
! O, D6 C1 z3 ]( X: ^9 e% nclear-all3 X, s* d6 P4 `
set-default-shape turtles "square"
& I G% ?/ N6 @4 Fcrt nutrition
" }: p1 ? n( B. Task turtles[
1 h+ a2 d' h3 C6 o set color white1 g6 k- _* B! B) R+ x( j
setxy random-pxcor random-pycor]
8 a& O. r) ^& V+ p
6 `$ r. t; v7 H2 i, n+ R4 w9 gask n-of microbes-initialization patches
' M+ x" R. `9 D) ~) y' K [ set pcolor green]
# s9 X, [- a" x. R3 n ask turtles [set energy 1]& {' u4 O4 i$ ?6 l5 h
end/ _! b6 k2 k8 U$ ^ p; c5 s; a
/ t+ ?+ s0 h0 a9 B ^6 C
to go
4 [8 |: x( @" v3 p% [7 ] ask turtles [set heading 90 * random 4 fd 1]5 ]6 F( D0 Q* W
ask patches with [ any? turtles-here]
+ y' q# M2 u M a) M" ]3 P [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
" c9 v+ r5 Z1 }. Z# B5 X ask turtles [ if energy = 0 [die ]]( o2 v' J* M/ R1 u% L% |, y" h9 d
end, ^; V+ N( J P. _% A
/ h! E7 d+ I! y! C2 H6 s2 q
to tt7 F* ?+ q+ Q! t# k" N
ask patches [set pcolor gray ]
4 d5 w+ P" Y( K Fask turtles [set energy energy - 1]
8 J( O! F: [# q. z) Iend* u7 `- \2 g# Q, @; @& b" }
: F5 d) e0 E7 i: y* X# ^) E |