请问:5 L4 J! Z8 E' K9 o4 L& q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
$ A0 Z- x: F+ q3 ^. d" Y$ S7 E. {( f' L8 k4 y" |; B* C! ]" h/ Y* b
8 ^* b( l% w, w. ?- {turtles-own [ energy ]2 K5 b, A8 b4 U9 C/ B4 }* A
to setup _ x' f: D/ o
clear-all
T" S+ T' s3 C% [! g9 j# Y+ x/ ]6 zset-default-shape turtles "square"
" W! I) L5 R( `, s7 vcrt nutrition% g; r& i# j* r" [& A. a
ask turtles[) C1 p& L3 D: V4 N+ _
set color white! t) g+ V$ U: h5 q# b# N8 @
setxy random-pxcor random-pycor]
+ ^0 _( H2 y* ~ ( `0 G/ W- {6 \# b8 X
ask n-of microbes-initialization patches
$ E4 ~8 E, B- V0 \( L [ set pcolor green]
9 Q* v! R) D1 H0 B& y" B( U ask turtles [set energy 1]
& U8 G& ?3 T0 X5 [end
& b5 o2 E) Y$ C
6 \. L$ `. |: ~to go; G- I% K8 S& P# P
ask turtles [set heading 90 * random 4 fd 1]" l0 T% ~% S0 J+ [& h2 ^ [0 r
ask patches with [ any? turtles-here]' R1 b8 n$ F7 L' L% r* V9 R0 A
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
# s O) [- ]& U& N6 H) J& p; G ask turtles [ if energy = 0 [die ]]
$ h4 M3 P( A) d' W end
( X! [$ F2 ^1 `' P4 Z/ z8 J5 N* k& b) Z( e
to tt. { Y) ?" E8 w: T% y
ask patches [set pcolor gray ]1 Q; X, b& n7 j4 J
ask turtles [set energy energy - 1]
% n, k4 O f# v7 W! k( o3 Aend' W+ ?% b( q* O( H, L, v) D
9 Y$ P! a- B* b5 n |