请问:
, ]& {0 ~; ~5 C# {8 A! z- m7 s随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
; i$ x( S$ o* E7 N5 U! \7 B) M- O O4 o
/ Q( A/ l0 b7 |! |6 d! A! Iturtles-own [ energy ]
! L6 Z2 {" J1 `; M) Xto setup1 p. S. W g5 L7 x6 f0 Y
clear-all
: E; ~' X& \; U8 y. ~set-default-shape turtles "square"9 e- ~1 E/ p- g
crt nutrition3 S" o- _' A- _+ ^
ask turtles[
( o" g- m% N ~' r; [, V set color white! u& z: U3 ~ l' D6 p7 }% l
setxy random-pxcor random-pycor], X1 k% z3 p# ]0 R
5 I. I' z N0 q A1 c4 \
ask n-of microbes-initialization patches: G! ?( e# G5 r: \8 h6 i; G! S
[ set pcolor green]7 A9 N1 x1 J/ h9 S. ` P1 q& W
ask turtles [set energy 1] g6 f/ w7 E7 o, V) Y" U
end/ s# x1 U) q$ ~( c! V# i
! {0 S* [1 e6 h1 l0 U
to go4 D+ e7 w" U4 X/ M2 Z2 I w
ask turtles [set heading 90 * random 4 fd 1]& B- K5 W$ k) K1 V8 k" N! W
ask patches with [ any? turtles-here]% x, d- `" g9 z+ h; k7 u
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
7 b) v; `$ e0 x; V( k2 u W ask turtles [ if energy = 0 [die ]]# j! {) e1 _& M* `
end
$ Z4 c, _# h7 N+ w4 z! q9 b6 r. t3 x+ l
to tt
# C/ _4 h2 w/ p4 l7 \ask patches [set pcolor gray ]
7 b! c3 P9 h2 p5 Q! nask turtles [set energy energy - 1]$ H/ A7 s- c; s. v" b
end6 F+ r/ h& B }2 C& u0 r _
1 [! q% \3 p" H |