请问:
3 S( A u$ ?% H% x* [0 {随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?) X7 E$ w$ y" n
; Y2 l$ ~* Y, Q% G
# D4 G& E" F: x; m( l* f, h# `
turtles-own [ energy ]( E- r: n% U/ w" F
to setup7 J1 A& W) l7 W! A5 q
clear-all
- Q) `8 ~, \) _6 f9 T* f5 Rset-default-shape turtles "square"
7 c5 n% b" G- } gcrt nutrition
; R/ s/ P$ q% a" Xask turtles[
; U* _* U, V: b" _ set color white
( @$ {$ H/ B# \7 K3 m setxy random-pxcor random-pycor]
! u: E; {, v8 {2 r1 N; V: I : i1 a6 L3 U$ P; a& W
ask n-of microbes-initialization patches
8 w& N* U& J E/ g [ set pcolor green]
" [( r) t- r' V8 N ask turtles [set energy 1]+ s1 w9 H; ~6 x+ b3 M
end' Y' S$ ]: Y" a* {
' R/ F- U- {2 W' C/ o
to go
* X1 R/ o# j: B ask turtles [set heading 90 * random 4 fd 1]: t0 Q& f- L, S" F4 s% X
ask patches with [ any? turtles-here]
0 k+ W' s9 d% C) S1 w$ ?8 v [ if pcolor = green and random 100 < chance-of-congregating [tt ]]+ L# |. h+ Q; m% r
ask turtles [ if energy = 0 [die ]]- b+ G4 i! I! D0 v1 O ^% n# h) D/ f
end4 u# w! H5 v- Z# \, s' P
: t9 a {2 H. |: h: ?
to tt( {: e F% n( [1 V2 `
ask patches [set pcolor gray ]9 H1 A# C- v* v. \; }. c
ask turtles [set energy energy - 1]
5 j. @; @# W6 @1 kend
1 P$ C% o6 R8 U* ]6 e' }1 n! i5 T9 s$ w$ ^; c7 n6 h1 i
|