请问:
6 T, N1 l+ _, O' f随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
- f2 j5 b* o: L4 R+ _0 O+ W
1 F- F+ T$ x! \9 i
* h& Z5 K8 m! Dturtles-own [ energy ]
# P; ]4 E5 M8 U' `) `. @. Bto setup- i* R V% B# S5 Z% I8 ~" Q" K
clear-all
- z, }, @% Z% O) y; y( j: Kset-default-shape turtles "square"6 a/ e& ~' G; l" b% _- Q( H" A% e
crt nutrition
5 X% y+ ?. L6 P( ? Sask turtles[
1 A+ g8 R ]) p. n7 p! _8 d set color white
. H1 J6 B8 p3 y+ |$ ~, v1 ?6 V) B5 x setxy random-pxcor random-pycor]
* |$ n5 C' K4 Q& N8 Z
: Q8 Z. o# N \0 sask n-of microbes-initialization patches. p; Z8 R8 h' o' w: ?. }9 y
[ set pcolor green] J9 y3 ?4 k1 C& ^ e. P% g
ask turtles [set energy 1]; ], V0 F* L; e5 Z6 }! O: c; \! J
end
8 t( u+ A, [- `& {( R0 T( X% R" A6 ^5 l$ ]
to go' W8 M! T3 B: O8 Z7 g2 E
ask turtles [set heading 90 * random 4 fd 1]
" Y9 g* S0 O- Y5 e) I1 A; ^ ask patches with [ any? turtles-here]
0 M5 k8 |. \8 s [ if pcolor = green and random 100 < chance-of-congregating [tt ]]' T* e9 a4 Q& T. p
ask turtles [ if energy = 0 [die ]]$ {+ w8 D: J. T$ D/ {
end, a% L6 C, H. j/ l' k. c$ Z! O
+ @$ v+ V# n! |2 ^: X
to tt
+ b0 a4 V. I7 S Q) L- ^ask patches [set pcolor gray ]
) e0 D: {5 t4 b, gask turtles [set energy energy - 1] Y0 S! N3 u% ]& u0 s) I6 [* y, a
end
( D4 M$ A8 P9 k& G
( F+ R3 L- i' ], ` |