请问:
/ N2 J( C/ K* G+ U6 m. A2 ?随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
& F* @% i4 _1 P7 e3 q% T$ I! Y1 N1 C# U4 e N, k2 o
( `9 m& {3 w7 ^
turtles-own [ energy ], H3 c/ L% r: R& K# `
to setup
5 m) j+ R, i" T1 C" _7 wclear-all3 ?2 @$ o/ y" v m
set-default-shape turtles "square"
. O# _" F, H. }7 U$ }5 Scrt nutrition5 l/ |$ S2 D- |7 `( J" ]
ask turtles[( A( a! v/ g- X, h1 A
set color white
' B" P3 G6 m: |7 L# o; r setxy random-pxcor random-pycor]
. H6 X6 I7 O$ g
! y+ ^. p' \/ k: k& P$ kask n-of microbes-initialization patches
|2 d: z' \6 Z& V& f: |2 O [ set pcolor green]$ a0 f d/ L* |9 z, T1 `" y
ask turtles [set energy 1]
, E- K$ X. r9 ]+ S; {end
" P+ G3 k0 }# x$ e
) g! a% ^: w2 H1 Nto go
$ n1 o8 l. U$ C& u ask turtles [set heading 90 * random 4 fd 1]8 \# z# w4 w1 z+ ~2 O
ask patches with [ any? turtles-here]7 n. x4 P' H5 I8 U$ E; O# n9 m
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]3 _. R% T3 Z2 K6 X) f O
ask turtles [ if energy = 0 [die ]]
% U' \; x2 x! j- V end
, _ J$ ?% J5 a2 T" O& Z. ]
: `, E% f. b( G5 {" P! T/ Eto tt& T. r* H6 u. w& `8 v6 Z
ask patches [set pcolor gray ]; C& \" S2 a6 O
ask turtles [set energy energy - 1]- L; |+ I* c; e1 l g
end
* P( M1 }: z s* _6 _, w) h6 U# J* T/ B, F3 v
|