请问:. P8 L" C6 w+ O* a
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
/ E+ Q/ n J2 E; n1 a
0 K/ L2 j8 r7 z ' D, b' v8 k4 s: o. K( ^, ]
turtles-own [ energy ]; q- R) B5 Q' k4 L' i& @. O( a
to setup
+ \* m; C5 J* p% F9 |. V0 u2 }% R+ Iclear-all
4 r3 W7 O+ H7 k) z' D6 q! K% Gset-default-shape turtles "square"0 `# d1 e: z1 u2 y# F8 W) s
crt nutrition# g# y) J V& O$ @3 d# V
ask turtles[. O# `% O: [% a* d
set color white
4 G1 y/ L; }' u* R setxy random-pxcor random-pycor]; M9 h8 {1 L5 i* T- Q5 L% _
2 j- I& A: q! q; z( B8 f8 e1 [* Qask n-of microbes-initialization patches
5 X* m) d4 t: B [ set pcolor green]
# i$ P& o! _9 H0 o" T# X ask turtles [set energy 1]
* p% l L" {" q) U, Z* gend# C- F' s2 l! k4 e6 u7 X
( S9 \1 w0 n: }6 {% E# @to go
/ q; \8 { y8 I ask turtles [set heading 90 * random 4 fd 1]
3 ~1 W4 j4 m/ B) P4 x8 g ask patches with [ any? turtles-here]* V' u- ~% G$ N) {& `# A8 E9 o% |) J( v
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]% e D2 U- C% Q
ask turtles [ if energy = 0 [die ]]
5 D# k% q. i% C$ R3 J4 j% Y end2 j( O1 y) x2 ~9 D6 ?# B
+ b ~. `6 @3 tto tt! w9 Z) D% O# k7 `1 N) C4 a1 k2 F8 K, E
ask patches [set pcolor gray ]$ d2 u* R/ c. z; ^
ask turtles [set energy energy - 1]
* u: P- D4 |0 A0 z7 Wend
% l+ u" E0 } S) H2 I* S3 b: q7 S4 K& s2 Q1 f9 d( ]
|