请问:( ], u) s- R2 P# G% u
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
5 c' K3 ~! h6 g, [4 }$ I$ z8 i0 F- B0 x5 t9 A5 O
9 I q1 ~. S. q* t7 H8 jturtles-own [ energy ]
& Q% E1 k" O+ h" P8 H$ _to setup" [) p) y. I* w9 P
clear-all
: l, K* N" e# f! W; F# \set-default-shape turtles "square"
8 i; A4 g$ T7 a q$ p3 y0 rcrt nutrition: S2 [; n& L+ H0 t, Z/ k4 T2 b
ask turtles[
" ~, O/ t4 B& b) `. J2 D3 K1 a set color white1 l) ~4 N1 |9 ?& q, u- J
setxy random-pxcor random-pycor]
8 o* q% l+ _, M- ^9 o / ?5 ~* ]: u; s; a8 P2 N# Q. F ^
ask n-of microbes-initialization patches; O5 a* s! }6 }8 D. |9 f, l
[ set pcolor green]# c V& A/ q/ ]! G9 _' x) Q
ask turtles [set energy 1]$ p6 }3 S, D9 z, P" y) s
end
6 d2 ?- @, C3 ~9 ~/ o! s# Z& I! n2 X
to go
3 g0 Y6 H! q6 Z) {9 I9 f& _0 h( X) R) Z/ J ask turtles [set heading 90 * random 4 fd 1]4 r2 Y ~- f9 ?: N! }5 f
ask patches with [ any? turtles-here]
# u& V* ? Q( i+ B+ i' c$ O [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
! {6 z0 ~: v8 x; @ ask turtles [ if energy = 0 [die ]]/ d. o6 W; N/ r$ o3 W! [% l
end$ Y1 u% S6 j- K9 Y- {- V4 M
) X9 ~$ i+ q: c& Z O" W- Cto tt
# w5 h; P; T+ N$ gask patches [set pcolor gray ]. N* P3 n" a6 S2 C' l @, h
ask turtles [set energy energy - 1]
8 w2 j0 H4 I7 |3 m; w. O8 \& s* lend
/ ]9 E; n! U% e4 q; H* d8 O# k+ D) t
|