请问:
9 Z8 l5 ?% T. p* k& k1 J随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?! A1 g' F& n3 ^9 u6 q# ?
9 O; C6 M) V: v( `% `3 ?
3 ?5 L2 V" J7 {& t; m% ^turtles-own [ energy ]
" N5 w0 m0 O4 D7 t, Xto setup
1 ~# d) E# a. c) R! B6 Iclear-all; F. ?; [1 M( v! y
set-default-shape turtles "square", U6 {7 t2 v# ^" b/ O+ b0 {4 C
crt nutrition( ^4 |; g; w' x @
ask turtles[
) T" w) \) s& l: t9 X& X set color white8 m) B; E/ O4 w8 l9 X
setxy random-pxcor random-pycor]
* L7 v) o% f) g h
, \$ Z1 C! Z- I9 n) k/ wask n-of microbes-initialization patches
! @ A$ M& l& N/ p3 ]2 A [ set pcolor green]
% q; |" j& Z4 ` ask turtles [set energy 1]* \# _. N; f: I8 p
end
# G2 @9 h7 U8 c/ p- ]$ P/ i0 P* [! @$ V) q" t6 K! x0 `
to go; w( {5 l8 Y: Q1 Z$ M) h5 K- m& J
ask turtles [set heading 90 * random 4 fd 1]6 ~- B$ m Y- s3 {
ask patches with [ any? turtles-here]
+ e" x8 R# {& O2 k( u6 l; I [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ \% \$ Z$ K7 |* O, t$ Y/ ^ ask turtles [ if energy = 0 [die ]]
" W+ Y8 N3 p7 t' n/ | end
6 ~9 B- N1 f% Y. T4 G: {8 Q) ?1 L' ~# C5 b* K
to tt
) `) W9 w4 E1 o8 [! k8 P+ Kask patches [set pcolor gray ]$ J9 l1 U# q8 c8 i3 W( Z) g( ?
ask turtles [set energy energy - 1]8 u+ X$ C/ N* B$ O; ?
end3 k9 N* `& o1 C( ~3 g
# h" F. U+ E# E- e% A |