请问:% T) J( G4 V% U
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?4 c5 U" i3 F# a% F5 ~
7 K i& i8 d% ^1 D7 v' L
" M& k: A) U9 ~turtles-own [ energy ]
+ b2 L# S" Y3 Y* | |" k9 Vto setup8 S( x& J# M* _9 j
clear-all
6 P+ d+ x1 o9 _% G- t/ a2 ^/ Cset-default-shape turtles "square"( t' `2 {3 E5 T5 E8 n3 P
crt nutrition
: Y4 b, ^: v- m$ ]! Kask turtles[
+ ?( N ]7 z4 k; Z' n! F" _2 w9 M& _% o! u set color white& |# ]- H- G( ?1 R9 F, m
setxy random-pxcor random-pycor]: w/ R r8 `4 v0 b8 R& S
% i5 w, t. K' ?- V/ `6 u
ask n-of microbes-initialization patches
& S" t; X/ j, m* F. i8 A7 V [ set pcolor green]' V! v# f4 d7 T$ ?/ k( e$ F k
ask turtles [set energy 1]! V1 O. r: ` _# i/ r9 b \
end
% Y! ?: R6 A3 [0 G# T! |7 [7 {+ o" ^" L& I
to go! G. k( P& A4 x' y, V4 W# W
ask turtles [set heading 90 * random 4 fd 1]4 _4 i) B- `1 k" P$ Q
ask patches with [ any? turtles-here]! c0 n4 J- Z! [: e+ U; f1 U
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]8 o1 _& j; @$ _- M9 n q3 `# a
ask turtles [ if energy = 0 [die ]]6 e! ~8 q. b% Z/ u) {6 F e# J
end
9 f2 q6 K M! ] |- x
# u0 M* d9 G( |. I4 V7 }4 ^1 I5 cto tt) U& O/ t( ?- G- W9 T5 k
ask patches [set pcolor gray ]
* R9 i1 p, e8 |6 Z* h/ Rask turtles [set energy energy - 1]" f% k2 C* X, c9 K- O7 |; `; X
end8 T5 a0 B" z1 u6 Y& [
$ b$ A! Y; ?: R h2 M5 f1 U |