请问:4 Q$ g' \* S4 U3 Q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?8 A5 Q( r' [1 G3 S
/ u- m( A! k% u
5 [. e/ B! [& f# X1 \turtles-own [ energy ]
4 Z! v$ ] o& E O" t1 z) y7 ^to setup% _% \( c2 x* _/ \3 b$ i v
clear-all: N, n0 Z5 X9 K/ w7 P4 f
set-default-shape turtles "square"
, S |; s& f4 w8 Y- L" jcrt nutrition& p3 Y6 K: {. `, t+ b5 r8 I0 [
ask turtles[
/ y2 S C4 D" i; e set color white
, F$ v$ q; q4 }$ p& E \0 }6 ~ setxy random-pxcor random-pycor]+ A) r5 ^ I! g
% d4 l0 S$ b. ?ask n-of microbes-initialization patches) {" n+ q6 f: k, v# t' K4 D
[ set pcolor green]
3 P7 R- L" j% ` ask turtles [set energy 1]
1 b0 Y- ~% k$ V& |2 O) ]* ]end
- N6 i" E1 T0 a3 S
0 p+ T' P0 [. oto go
- f# s4 K" Y0 i+ v: G/ x# u) `2 w' M6 T9 z ask turtles [set heading 90 * random 4 fd 1]" m# w3 s9 ?& Q+ ]- j r V
ask patches with [ any? turtles-here]. r" ^1 f$ [7 m
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
- O/ W: o: m& s Z" P9 I3 t* Q# S: q ask turtles [ if energy = 0 [die ]]# s$ u/ g. V( O1 A x
end- N, d3 @: ]: `
8 V0 a0 p+ b) r0 L Wto tt( C) J+ O8 b4 I3 {4 }/ a0 q" q+ B
ask patches [set pcolor gray ]( P' o5 a" d/ Y2 U
ask turtles [set energy energy - 1]# O k$ E& X" j2 f! K# u. b
end
; S4 H- o. L! ?' ]( U2 D4 V; V2 z8 S0 T1 O; p% \3 m
|