请问:& Q' o- G7 S4 T J# c7 u
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
( j3 I: G/ O$ e4 A
4 D- d8 ^! `5 f/ `/ k0 Q2 B9 l & H% {6 [* \( ]1 F6 @! w( R/ ~
turtles-own [ energy ]
! k' R9 U& c2 c- e9 {to setup+ I, ?" {9 x9 ~ a" }
clear-all
; y( O: B/ B0 ?, t& sset-default-shape turtles "square". x5 M! D* p, m: u$ {; v4 G* `. K
crt nutrition1 I; E) V0 a# j! L7 d
ask turtles[
" Z0 x4 Q8 s( o. a set color white
! ~+ S' a) o5 k$ s# W( \+ x. [ setxy random-pxcor random-pycor]( o% R9 M. y2 w2 ?
( Z7 f& j3 |6 f( [4 D( i" U0 n- e& d
ask n-of microbes-initialization patches
- v% @ c. C8 T2 d [ set pcolor green], ^7 N! p0 r3 i
ask turtles [set energy 1]
* r# V5 ~9 ]4 O+ E# i1 Dend
" J8 z5 B$ `4 t/ k8 G! N1 v( _
# S& s4 H! f5 Y* w& \9 L5 z/ Vto go
A) L! i ]5 t% s ask turtles [set heading 90 * random 4 fd 1]
- [3 q ~$ i1 C" ` ask patches with [ any? turtles-here]% ]$ j* y7 o/ T# n. }1 w
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]- y9 ` A! r7 Q, E) y9 o
ask turtles [ if energy = 0 [die ]]$ h4 t' l3 j6 D6 X/ ]$ Z
end8 w$ p& G# U7 k, m3 L
7 K* L- v8 r+ s
to tt6 m% w' {2 i; i* }9 S
ask patches [set pcolor gray ]
) t. m9 u, i4 t* `- `ask turtles [set energy energy - 1]+ F$ }; G) m3 y
end! D% m" c# `5 z; e g
) p7 Z5 w: p& t& h- t/ c7 `! X
|