请问:5 T" T! J3 ]' M, X
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?$ |; L6 M' N5 f. k5 B g9 f: C
1 L9 }) O8 o: |# |. u* }1 o0 P
9 l$ |* J8 o4 K0 Aturtles-own [ energy ]8 \: d5 u7 M* ^: X& d+ K/ e, l
to setup
& F; @; U- g; U+ `5 Y$ Pclear-all9 ~* R' C- R {, w2 Z1 {
set-default-shape turtles "square"% y2 d: ]: r0 O. ~. r) g* C
crt nutrition& e3 i4 I& J9 k% H9 e+ }) s6 e
ask turtles[
$ R1 ^. E. w5 J, Z set color white
" E8 O/ y5 H" E4 P setxy random-pxcor random-pycor]
% y. i* o7 N0 [- W7 `( N- O 0 Y* V6 ~( |7 Y
ask n-of microbes-initialization patches
7 {$ T$ Q8 O& w2 @& S2 q3 S [ set pcolor green]
' R$ }2 A: r. A* o" Y% ^3 }8 H: E ask turtles [set energy 1]( Q1 M( v- A8 s5 S# d% r
end- |" g/ D3 v: r3 i; ^4 R4 x! x! X
7 K( E! F5 Z9 X7 B
to go
- d6 z/ X4 Y* v3 J% W$ y ask turtles [set heading 90 * random 4 fd 1]. v' U" ~! z* Z+ A0 Y# b8 E
ask patches with [ any? turtles-here]
! N; r% K; ~- L4 r [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
. F& {+ O7 a/ R# `- j# u ask turtles [ if energy = 0 [die ]]: a) K% \; e& X' e6 y+ X
end4 Z0 W# K9 o0 ]* N; b
4 b: t) r( M' g. C1 w+ Oto tt( Q9 n y8 n3 |" R. [: i
ask patches [set pcolor gray ]
4 F4 B: w% q0 _ask turtles [set energy energy - 1]7 L4 p0 J% \& d
end
5 [) h* c2 X5 c# o
! Y. j' R1 l x |