请问:$ Z, i4 q! K* O( e
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?, P U0 `, g/ y# i/ J# Y/ L* A
c5 L; n/ @, m# @2 T
# o/ S& j. |1 r9 x# C" b0 k0 n9 Cturtles-own [ energy ]; ~- @/ W( H C. _' x& t; u
to setup
/ U( y1 B' P* a; X7 v' Iclear-all
! |8 K4 W f7 oset-default-shape turtles "square"8 P1 E6 b9 |8 S- v: ~: i# h
crt nutrition7 {' b. Y) W- {, @
ask turtles[, [3 j& g1 |/ l [2 e' W
set color white# m) p! j/ w( Z A+ d
setxy random-pxcor random-pycor]4 t" b" R% S" A* A$ L v" G
1 W# K) I9 z& ]/ D. m( y6 M2 N) }" w
ask n-of microbes-initialization patches
6 N0 b8 a; W4 V; v [ set pcolor green]7 S3 X5 h2 O/ g% v) Y! T0 z- g
ask turtles [set energy 1]
: F: y3 I: f' t7 gend
* K/ T. z# s2 V; R2 q2 x; b8 X$ Z$ M. i2 R9 [/ \
to go
9 H" |* x9 H, d4 S& i8 n. N/ n+ u ask turtles [set heading 90 * random 4 fd 1]$ ]1 }& E& T) ?- e, I5 Y
ask patches with [ any? turtles-here], \) a+ {1 x; r( E9 V
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]' C6 Y0 {1 P( a- G: y7 v
ask turtles [ if energy = 0 [die ]]* w# H" x/ ^" n2 o" |; N
end' w& V# J- v o& x
; i/ x' L; Y! Z3 `+ ato tt
0 `; E: D$ e9 m5 y. l1 Q8 ]+ Aask patches [set pcolor gray ]- B% g7 }& y) w
ask turtles [set energy energy - 1]. q; x* H8 k9 A& p l3 N+ C
end
: `0 e* U. i' R, \# \; Q, R- T1 D2 V5 k
|