请问:& `6 _ y' s* ~% y
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
k% \! a. W4 j( M
' ^0 @. L! R8 |9 J7 n6 K9 ~
1 n8 O+ G, G7 x' `turtles-own [ energy ]
6 N% c S7 r9 M2 y6 V ?, S0 j, ^0 n hto setup$ \: v; _0 w: H4 |
clear-all
( [# Y! d5 p" P# a% H3 a: }set-default-shape turtles "square"
0 @( V, x8 D- D( scrt nutrition: [6 D* F7 z. s: ^
ask turtles[: X/ {: Y8 d2 k# d+ G( z
set color white+ |/ D+ k; W. t B$ r
setxy random-pxcor random-pycor]
" x; G) t, r& @* `) U , J4 J1 |' }# a, g
ask n-of microbes-initialization patches
+ a' x$ J8 B/ e* F# a [ set pcolor green]
- a: E* e# u# c ask turtles [set energy 1]
/ N' l) d7 B5 `( z- L7 v1 \( qend+ `$ o7 b2 W; a9 R! o8 Q
$ p/ }# s; I4 r
to go0 L6 n0 s1 X: s7 n5 w2 I
ask turtles [set heading 90 * random 4 fd 1]
* j& w" H, o: d6 ~ ask patches with [ any? turtles-here]
: y0 K/ z7 W0 g; j2 M [ if pcolor = green and random 100 < chance-of-congregating [tt ]]6 {1 ~4 z) ]! S4 j7 [" f7 F
ask turtles [ if energy = 0 [die ]]
) C" W2 q/ Z E, w: m4 |! T6 @ end
, C) v5 h. k/ B8 D2 H0 i
. N% w$ Y7 T: N* J4 l( B7 z5 ~to tt* z# m- H8 t' P* g3 e& [
ask patches [set pcolor gray ]3 y8 [: y; @* w
ask turtles [set energy energy - 1]
7 W J1 n2 d$ G/ send, G( O: L: [' ~5 [
, _( l' G! C4 u& S: g4 {) V |