请问:$ |1 j1 ^% J7 | _# j
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
* Q. t+ ]6 w) b4 x$ Z% ~7 Z& s5 h# ?( D+ I/ N. x9 R8 u
& X1 O8 a! n5 T, r, H) O) `( W8 ]turtles-own [ energy ] i6 F" R4 f+ \- x+ S% Q
to setup! N, Q# V* L& ~2 S
clear-all2 h9 H7 e6 i! r8 M- A9 k2 N
set-default-shape turtles "square"9 w' ~- U: G" }+ ]% P5 C3 |! ~9 ?( I
crt nutrition9 x# w! v5 q# @+ f6 g6 b" V
ask turtles[
; ^8 N6 z# S# M set color white! }7 ~3 G% I/ Q1 v3 J% e3 J0 S4 q
setxy random-pxcor random-pycor]
% Q' p% c' i# S1 \# ^. P3 @7 q3 n: { . F$ N7 I2 H6 w& G! R
ask n-of microbes-initialization patches
! G3 L6 z7 L! w3 F. g5 b6 l [ set pcolor green]5 E. \6 i- ]6 d! N) N8 |
ask turtles [set energy 1]+ V3 g3 Q6 H) R1 E
end
' ^$ W. m& F% v2 j; S3 F1 s& h# [, F9 u# J& `7 y+ S; ~
to go3 i2 K, S% C6 B' b _5 z6 s$ f
ask turtles [set heading 90 * random 4 fd 1]6 v3 S. K0 N! D9 c5 g h
ask patches with [ any? turtles-here]
# g y/ ]4 S$ w3 A- ~8 _ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% Z/ X9 h4 \- Y/ x6 l1 P G8 @0 \2 }
ask turtles [ if energy = 0 [die ]]
d& A+ _! ~! t) C0 S" Z$ I) N end
% y" v7 w3 G$ L2 ?0 }
2 r3 s# ?( j0 G& m! ito tt
* { u; B6 b7 f& K$ Z9 z) fask patches [set pcolor gray ]2 \, _" B2 g6 v4 e9 ?' y0 N
ask turtles [set energy energy - 1]
! r5 x8 |2 e1 e2 Q6 ]0 A2 Kend0 P2 ~# w _4 o
4 M* |2 Y) a+ C2 ] |