请问:; D9 D& [ e7 A. @
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 P9 i% F$ d+ W2 Z5 K
" k, _ f9 g; u- a/ H) c" w
6 x) U$ h- X- _+ c& |; }' G6 B7 {* W. Jturtles-own [ energy ]
% N) O8 r. h- V9 t# X* k. ?to setup
- \; s3 v+ V8 R# zclear-all
) \4 C! Z5 V' f vset-default-shape turtles "square"3 V0 h& r9 U7 `4 t
crt nutrition
2 [" M1 ~" P& Xask turtles[
. \. Y5 q+ U4 y$ W. ~! L2 F set color white: ?& V5 G' ^; M5 Y% R {
setxy random-pxcor random-pycor], m- E2 c& g5 |( ]0 p
9 B; k" ]$ ?! ^7 U8 S
ask n-of microbes-initialization patches. b- T! U3 V5 D
[ set pcolor green]2 j, N4 m1 r! _- [5 t
ask turtles [set energy 1]
* s) O0 S: ?6 r+ }; S: s: kend
6 J F; l* k' Z6 n) Q( k8 n: `* Q6 @
to go
S( k# {) h0 j. S4 o ask turtles [set heading 90 * random 4 fd 1]6 t E4 t% d# i
ask patches with [ any? turtles-here]
+ R- h2 B* J) e. X$ S [ if pcolor = green and random 100 < chance-of-congregating [tt ]]* j" x, c1 Y) c$ }/ h. p
ask turtles [ if energy = 0 [die ]]
: f3 Z9 H( @& u! f end
. Z3 k) d9 K: S r! a7 X% X% e! E/ f F7 _- q8 I7 ?6 d+ V
to tt" r" o2 h. F m: J/ i G6 H
ask patches [set pcolor gray ]
+ `2 j& @$ `8 V& sask turtles [set energy energy - 1]8 v9 C- \: ?/ M8 U, N9 c7 s
end
5 b+ K5 F% r0 h8 i7 j1 w+ [
, K" }6 d2 a- ~4 F2 A L |