请问:3 V- i) v: Z) G- F
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
1 ? R1 u; f p" ^
% F8 Y1 T% W; a
1 y( J R2 Q8 H( K* @- G# z2 e1 hturtles-own [ energy ]6 t, c3 v* z6 N3 w7 Y" q
to setup
* W- P. O% p+ C2 ~( E( }clear-all
+ S6 j% F/ f" r' B& W0 x; N$ p2 X6 sset-default-shape turtles "square") x1 S4 E* a) Z! a' U
crt nutrition6 F- i9 P `3 W+ K6 k: r& P
ask turtles[
2 }0 s! _1 R' m( \7 h7 O! q set color white, h) p; D/ S b5 Z0 C9 u# P
setxy random-pxcor random-pycor]' W5 {3 G9 \( n9 Q2 m7 Z
# c9 k3 i; C8 D/ c
ask n-of microbes-initialization patches
) Z( M5 W5 E; a+ r5 @2 I [ set pcolor green]
; y% A. c$ J* R; Q ask turtles [set energy 1]4 c1 K- \5 N" G& e
end0 o' v3 K1 \5 k+ z
- Z4 u/ d0 M# F6 Mto go+ }# W( [6 z u/ \( i8 X" B5 }
ask turtles [set heading 90 * random 4 fd 1]
- Q* \ ]4 s# ~& u0 b1 P6 } ask patches with [ any? turtles-here]
' Z" I7 A; r8 P& x7 }0 I [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
* k+ ]- K% z0 e/ w, @ ask turtles [ if energy = 0 [die ]]
6 `. B# s o7 ` end# S% `8 l* w# c6 r. y
) b6 m9 {$ b* Uto tt+ ]1 c& @: |+ p* t$ b5 U1 F
ask patches [set pcolor gray ]
9 x! w- e/ V% lask turtles [set energy energy - 1]
9 B8 ]" C5 E, g" S' eend Z U, [, S9 }6 C: J) z, h
4 R% h) ^# G7 }5 ]5 T |