请问:
- l u$ b9 G, A6 _: k. ]5 P随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
. F4 `! B7 D3 c# ~. L. q
7 h4 D5 Y, M( k
& i" T2 M4 {2 a0 b! L1 ~& v% a& mturtles-own [ energy ]+ x* @$ j" }. \ l$ C9 D. O9 K2 \
to setup
2 w3 B" G: Z- p' P! [/ Bclear-all
4 k" N6 Q& \0 n0 L+ V; E0 F+ }set-default-shape turtles "square"3 Y" Y4 k3 Q5 \4 D! V! H, f J3 t4 L
crt nutrition" H3 n" P) \% Q6 m3 ]8 Q( d0 l
ask turtles[
3 B; m0 G4 S- y9 ? set color white
- \4 A% |+ U' \% w1 b setxy random-pxcor random-pycor]
6 N" m0 N6 {+ s5 e# d9 x
3 D3 W2 z( p" W5 g" u( Cask n-of microbes-initialization patches
) G' w2 `! g( |. l [ set pcolor green]$ e+ Q- W( J+ ^4 ^ `6 H
ask turtles [set energy 1]
- U. L3 `9 m3 I8 g6 `+ p. gend
7 x$ J- ]7 _5 Q9 R/ x! _& i* g" G3 ^( d5 q, v8 V
to go
% q3 p7 z! s. d) r6 b ask turtles [set heading 90 * random 4 fd 1]
- @, R5 u& t j s ask patches with [ any? turtles-here]8 j6 X4 v7 }- N3 E* N- {0 p$ C
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
5 Y4 d# }( z# ] a9 U0 d ask turtles [ if energy = 0 [die ]]
8 u6 j' J( F+ g o- F4 A3 B6 M( X9 ?+ U- l end
# Y" H2 [3 }, E$ ^% |) J: h5 |
8 g" u9 Y+ t- y% `6 pto tt
) x; j; x8 M7 g# V3 B# K9 V9 |+ _ask patches [set pcolor gray ]
4 s8 x* c. Y" v- c5 mask turtles [set energy energy - 1]
- i& {; E0 A/ f. ^1 [/ w6 S# l8 }end
. d" n" W# I# ^" U/ w
7 y X) R- a, l. } |