请问:
. d" }! H# [7 H0 k. E6 F9 v- M$ Z1 j" F, B随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
5 h' V5 |9 g9 Q1 ]5 A3 [" H
8 a$ z4 T% I# l I& Z7 r& @1 Z: a " _* {) ]% G+ \& Z: i9 V7 K, E
turtles-own [ energy ]6 U8 n# Z/ O; l; n! E3 N" j
to setup
# N1 d( W) x" y, E1 tclear-all
6 `9 T7 _+ J- m/ |$ ]set-default-shape turtles "square"5 Z* l) m2 u- v. ^/ R; i
crt nutrition% J! ~( b2 @1 R6 a
ask turtles[8 b9 ^9 F4 y3 r" h+ V' b
set color white) b1 o& m+ C- m9 L! h3 u
setxy random-pxcor random-pycor]7 e& w7 I! q; O% ^. j6 B
0 V D! w# R9 E r) b
ask n-of microbes-initialization patches* a. l& i+ g2 ]8 C. f
[ set pcolor green]! L) A7 U; F- M% o2 r: E
ask turtles [set energy 1]/ v$ L! K- C- I% ~8 ?$ Z
end; H7 `- [, n4 P( f0 }) s# w. p% Z0 `
h6 O0 X$ p/ `8 w- c9 g. T, u
to go
4 i: p% n2 `2 _4 S/ P% N ask turtles [set heading 90 * random 4 fd 1]
# |! I+ f5 N2 O5 S! V% [# Q2 N ask patches with [ any? turtles-here]0 M9 n- }! j q: l1 [
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
: o: s! u7 I/ n) i9 _- d' U ask turtles [ if energy = 0 [die ]]
' w4 r8 c# x% Z0 R end
8 S. Q. G; ~% I# M( d( M" ~* V3 x7 r$ \
to tt
. F: D( ~ b+ C+ Rask patches [set pcolor gray ]9 @% c* y" R. ]& ~2 o7 M$ Q
ask turtles [set energy energy - 1]: ^ _7 N+ G% a0 a* v% j
end
4 U+ z9 |0 a$ u# E* U
/ K& F. p+ O( `1 C" m- A9 F |