请问:5 w) ^9 n) m& X; h5 s; Y
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
9 U( M, d$ V8 t+ n
% m- b! A* [8 }
1 z" ]3 i, S2 f) I9 W2 h& vturtles-own [ energy ]$ S' w8 H( I3 a. t4 U0 Q
to setup
1 X; _$ |; a* pclear-all
, o8 y7 I; L) n0 u4 uset-default-shape turtles "square"
) e w3 |% _$ icrt nutrition
- k" m1 \( f a; wask turtles[" K6 ~$ ?5 z2 L2 m0 T0 ^
set color white
7 ?7 O" M$ O+ Z8 [3 }5 k2 T, B! D setxy random-pxcor random-pycor]
7 [, N! D5 G% ?$ p ) m- I( j# t# q* D6 o- u
ask n-of microbes-initialization patches
/ N1 {# r) }. m5 z [ set pcolor green]
* B8 Z6 O# ~( Y# V6 l- D ask turtles [set energy 1]5 V3 [, U0 J# E* E% V* g6 G
end) S& A6 M6 ^. H! ^
& ?3 R+ `! F0 z& q" i5 m. z; f
to go1 c0 p1 Y/ R+ X/ J9 S" o2 T* `
ask turtles [set heading 90 * random 4 fd 1]0 U1 K w6 j, Z
ask patches with [ any? turtles-here]# c% I7 X# t! G& d7 u! k3 w9 E
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]& o* o/ L- Q7 Q# q8 W* b
ask turtles [ if energy = 0 [die ]]
! `' X/ d' @4 A$ p# T& l end
- `0 h7 y. J+ d; u/ v4 k) Z! m) P2 C. X U% ]2 b
to tt
3 m3 S. C- o% s6 d/ D( gask patches [set pcolor gray ]3 M% s$ p7 r2 R% O
ask turtles [set energy energy - 1]! W5 L% ?" O" }/ U( S& f
end% B5 q$ H+ L) ~1 j* S
7 ^6 b" K$ B3 h! E" w5 y
|