请问:+ m1 V: C% Y# [4 x3 E* S# J
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" p' N) U4 x, \$ i
4 H5 {- @6 y. d Z: C9 i" U * s! Z3 q! e$ N0 }
turtles-own [ energy ]
/ L( j: u) z. `+ pto setup* _6 ]9 i0 [( Y2 N
clear-all/ B# x4 B% e3 n
set-default-shape turtles "square"
3 H; [. V+ [7 Q, u' ?crt nutrition1 I5 W4 O. F% M7 E2 a: t3 x
ask turtles[
" m+ U1 g! u! {+ | x set color white' s1 c- D6 q3 r
setxy random-pxcor random-pycor]1 W- `0 f' E5 @) R
0 Z8 y) S! A8 W% X, N
ask n-of microbes-initialization patches- a/ ], N6 }% p( ] s/ Q; G
[ set pcolor green]
0 i# P6 y, {% o" A; G- C/ T ask turtles [set energy 1]' `) Q9 h) s5 M$ Z8 A: }
end
1 M; C/ z2 ]7 K3 z* b
% s, R$ ], k# ~: pto go
. s4 h; c2 F7 \: F ask turtles [set heading 90 * random 4 fd 1]
: F6 x/ c; _1 }% C" U ask patches with [ any? turtles-here]+ E# K: P9 V2 V8 `
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]5 }. J7 }- p7 j X1 e6 Q
ask turtles [ if energy = 0 [die ]]
3 B' G: H( G$ P! I# _ end p) d! H: z# ?5 |$ x& U
4 V& U% v+ h8 w! a& _
to tt: ]0 S. F3 R8 A: O
ask patches [set pcolor gray ]
B8 n5 r3 H+ q; j7 B z" E7 K, B" eask turtles [set energy energy - 1]; ~, e! U. o9 ? M, [7 N
end* O: ^! H9 _9 h9 t. j
5 ^, ~1 L1 H- D9 @' z- b
|