请问:
2 j5 M1 ~: Q6 d5 L5 z; y$ k随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
- ~5 i- K) E' s' N" \) t5 k2 ~* g5 z& h: }
8 v" x* F3 \9 ~" Qturtles-own [ energy ]
3 R# ?& f- M) ^$ |2 H* Qto setup2 e/ M9 h# i+ M" k' f
clear-all9 n( L7 ?2 R2 [( c
set-default-shape turtles "square"
8 f% z3 I7 M5 L2 lcrt nutrition
0 o; X9 l8 q* P" uask turtles[: ^8 |& r g, f9 u. i: T. z
set color white! Q. C9 |# B9 s1 t- U6 S2 Q! D
setxy random-pxcor random-pycor]( U/ X C/ W3 R2 w+ W
( K6 z$ v9 f- [! v
ask n-of microbes-initialization patches
9 ?) |7 a k3 M [ set pcolor green]1 t7 g2 }6 i# P" N; N2 I8 k. ]
ask turtles [set energy 1]
0 r2 l1 |9 `/ c- s( m0 Xend
% l2 h% \0 b. o7 e& I% W0 g2 L' ^' a# S6 C j3 _" l; b
to go
: d W e. q3 I' D, a9 h% K' L ask turtles [set heading 90 * random 4 fd 1]* L2 W& G7 I# @7 V0 W7 [% S
ask patches with [ any? turtles-here]
. \6 J2 o$ ^, k: q, N [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
$ K k7 B$ u1 J- a# A9 ]8 l ask turtles [ if energy = 0 [die ]]7 ?, C) i* T' s- a
end6 [0 y _' h4 s6 o7 _$ z
1 {0 N4 a5 M( ]* l0 Z& tto tt' ]. R6 J2 {. C& M# `) l8 s0 Y' J
ask patches [set pcolor gray ]1 C2 c7 v- V& I# o' y
ask turtles [set energy energy - 1]
1 ?8 P: r. i4 k- X6 xend, q9 B9 R: a" F1 l3 C
0 h( w$ `1 D! q/ s
|