请问:
p$ r- q1 V, P0 U" f$ M随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
# |* Z, i I6 p) \1 B0 J
" W2 G: O5 @ w- d. a7 g2 D 1 F% G# }' U& K) ~6 r& f
turtles-own [ energy ]
2 A3 i: d i% X9 P# lto setup+ P2 w7 y0 l5 U( P
clear-all. P3 i& |; p) j2 G
set-default-shape turtles "square"
# ], d& T) V; Z. ]4 pcrt nutrition* k+ ]* ?+ P/ `: n( K# M
ask turtles[3 K# p) F, @4 x9 g! g
set color white& |( u4 |! k3 z) g0 [) U* k
setxy random-pxcor random-pycor]
9 C: @( @3 }& A3 n $ |- ~- ^3 ^% a1 X/ s3 a
ask n-of microbes-initialization patches' c" B5 V, R$ D4 P/ r
[ set pcolor green]8 q2 N1 T3 m2 Y3 z/ ]9 n8 l
ask turtles [set energy 1]
2 E8 [5 g) Q# }9 Y- g0 @/ }end6 Z* w" W" p( _0 y4 c
! X4 i. N' O0 H1 O* e. @; h9 m
to go( L6 {9 Y7 c4 Z* a
ask turtles [set heading 90 * random 4 fd 1]
: f Y9 P9 h, I! v3 @ ask patches with [ any? turtles-here] l; a3 s- j) s" L
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
- m0 `( R, r( ]& L3 r, r5 | ask turtles [ if energy = 0 [die ]]
1 k+ A. |1 p3 ~" { end
( q. V7 x) D! H
0 L; J2 o: w1 b) N- C8 Rto tt
. q6 r3 H" w; h8 H7 y: K7 r3 |9 w) ?' yask patches [set pcolor gray ]
0 d, R- _6 |% Nask turtles [set energy energy - 1]
; W" {: O0 ^3 Eend% D- K. V0 J2 u9 D8 `$ H' J2 w& d
3 u$ c/ @, Z9 X8 f y/ G) e; \ |