请问:2 [( G* f9 L1 m/ k* ?1 V2 E0 ?6 _
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
) E9 I# H. a7 ?" S% ~7 |) r. J0 U1 B
. t# g7 _4 W5 M6 I% t& l$ a1 y
turtles-own [ energy ]9 k P# u. [* j0 N
to setup
/ n! C& l8 @& E* I& [/ ?clear-all4 A! O8 d2 R |/ z6 h# d
set-default-shape turtles "square"
! n) V7 X- M+ ?: c) kcrt nutrition! Z% _8 q8 f5 V, `
ask turtles[
7 r& E0 S4 \( i# n3 i! L set color white8 Z S: w y5 C+ H
setxy random-pxcor random-pycor]
) A+ ~5 ?, v3 L+ n A8 }% T
5 _. ^' h2 @" U; s: S! @; Task n-of microbes-initialization patches
8 z2 z& H7 V6 X/ F2 h [ set pcolor green]5 q& M& P" g: r' D& z" h* i5 R
ask turtles [set energy 1]
# l- Q2 R* q- q0 D* \end3 p' n! D% b4 {
! E0 m6 f4 G( G" a: ]5 P7 Y8 X
to go
4 q# D2 d/ z4 Y5 H. X6 w* f ask turtles [set heading 90 * random 4 fd 1]
& {, d: L$ Y( W ask patches with [ any? turtles-here]4 A5 t# \# |1 Y& w+ Q% {. B
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
1 D7 k J1 l. c& x ask turtles [ if energy = 0 [die ]]
# @7 [3 p* i' |% \ end
6 `" ?" Y) R& a9 }. U' K" H# C- `- U, u+ z6 |
to tt
7 m/ o: U4 w. `. y3 k8 Y, vask patches [set pcolor gray ]7 _. L: o. s: v8 @0 J7 J0 |
ask turtles [set energy energy - 1]
, r# j. r4 `* i. k: Zend9 O% {) [6 c# `
2 Q0 ~8 a1 K6 f# j/ P, l- P0 I9 N
|