请问:! h4 g2 J1 N1 {0 `
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
* g* |( u Q& K" x1 w- W: n
6 f* A1 _8 N8 \ * R3 e( j. b8 \ }# S4 r2 Q* h' w1 U
turtles-own [ energy ]: x& |5 y# [0 D7 d) \1 Y2 Y
to setup6 H- R+ i2 y; E, u
clear-all
5 ~/ Y$ |5 I6 Y0 l% a1 A: ? u; Gset-default-shape turtles "square"5 K! E4 @" i* R
crt nutrition
# j" |. q: F8 A' qask turtles[
8 q t% B; [2 F6 K set color white
/ s) B# I8 o. c4 C setxy random-pxcor random-pycor]
5 I9 p+ m, B& W" H+ f
3 r9 p0 ~; R9 ?! [; u# bask n-of microbes-initialization patches. H, k0 S3 l, g* }
[ set pcolor green]
* {' i; N# E/ O3 Y/ K8 C ask turtles [set energy 1]
5 X% |2 S1 V8 mend
" y" V/ J$ z: @: D0 e, j" H3 }6 Z$ u+ f. _. l+ g; x1 N
to go
. T5 G3 C( |* B ask turtles [set heading 90 * random 4 fd 1]# ?7 k0 U1 t7 `1 b) M7 R5 p) `4 d
ask patches with [ any? turtles-here]* q6 j7 w2 Y. G1 \
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
9 V, @& ]0 ?9 s6 | ask turtles [ if energy = 0 [die ]]$ \0 \/ ~: b$ @: P+ H
end
3 x# j% `) I3 j; l/ [' K& F a4 e- h# a
to tt
5 ]5 Y4 s4 J: \" | f. ?0 j& |ask patches [set pcolor gray ]
$ I/ N1 B; C* A' R' r8 R8 Dask turtles [set energy energy - 1]5 J$ T4 A; f( w; l. B2 z. ?
end
9 e* V1 k) K& J; P3 {8 m1 t1 N9 L" ?' M- v# N# K
|