请问:7 d& f5 I. E7 {! y! e- f
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
/ ^/ h$ J/ J0 N, i; Y& A% b1 K9 s# {
8 f- c! ]' n9 s) L! ]1 g9 Gturtles-own [ energy ]6 B+ y' i9 w0 s
to setup
- D( B6 H& D% x3 [4 uclear-all6 Y3 \( Y; X2 j! K8 L
set-default-shape turtles "square"8 |* `7 G h- e! O9 A' `
crt nutrition
/ ~& ?% ?& u c$ L, b6 r, iask turtles[
$ t T- y3 ~$ D) v M set color white2 {6 I8 Q2 X( ?: |2 w, a' }3 l2 D
setxy random-pxcor random-pycor]9 G- Y6 n8 J1 J" t! l! A; Q% ]
- e7 M- N- [7 {* t
ask n-of microbes-initialization patches
# _9 V- E! S. ]1 M/ p [ set pcolor green]
& I& f+ Y/ v3 h1 P ask turtles [set energy 1]' o7 }/ n/ U4 ^4 B
end
! t {- l. S7 i
" x8 x X! d/ P& Ato go
( _/ {7 W4 a/ G5 Z( x ask turtles [set heading 90 * random 4 fd 1] h4 m( F% W- \7 m$ g
ask patches with [ any? turtles-here]
7 R0 t; m4 k3 L" _3 f8 ~ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
, Y! s* l$ o- M0 q8 T5 I ask turtles [ if energy = 0 [die ]]9 m# c: w1 {1 ?5 Y
end+ ^5 R, L: U g: q4 B2 b$ Z( i5 |
! ]! l. S3 r+ L
to tt( }( m5 a/ X- ~/ s |9 `* A
ask patches [set pcolor gray ], `7 m' Z4 @, ?" r4 Y6 ~0 J, F1 H
ask turtles [set energy energy - 1]
, H. E9 d* t/ s- L' X: cend7 J! y9 n9 v) `( g# H
) B3 g- N9 h* B+ O$ O) D: h |