请问:* _ a' l/ N" t& h
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
( _: C G- j" r }6 S+ e3 n) [6 w, B, ^' W
! }/ S$ ^$ C( k! s4 q/ \, a( p- b, M
turtles-own [ energy ] E7 N+ i2 a3 C
to setup% A' H- X O, r
clear-all* N* e( N) ~/ M
set-default-shape turtles "square"
7 l' O b5 b" f+ u3 Zcrt nutrition) G8 g: b) e$ W1 N: m
ask turtles[
1 i3 r: ^5 p2 P+ z% ]; l set color white
+ ^$ V- i1 C/ j6 f- T/ p6 \ setxy random-pxcor random-pycor]
# D6 r9 n- [# G) [9 Q7 C 1 R t; V+ Q2 @/ w7 x) ^0 e) _
ask n-of microbes-initialization patches
5 q( e8 ?. t L" n [ set pcolor green]# `9 Y' \. q+ H4 Y
ask turtles [set energy 1]
/ \9 B) B4 f- bend9 T1 P5 d4 \7 ^9 R: T4 K6 K
) B Q. w V3 x! C+ h! Ato go
! `0 i& P; I* r2 p5 [% Y ask turtles [set heading 90 * random 4 fd 1]- x g- a/ T* @) x6 R
ask patches with [ any? turtles-here]
" F5 |8 d o& y- P: U [ if pcolor = green and random 100 < chance-of-congregating [tt ]]: L8 \; e* P% q- ?" C
ask turtles [ if energy = 0 [die ]]
3 i' m) F7 Z2 j4 F' ^ end
9 L: ^3 x3 w% H
8 G% i1 r( P$ d* o9 u% B" sto tt
3 O: l+ }) m/ b$ }0 u( a/ }ask patches [set pcolor gray ], A5 V" E4 i! |9 Q" n% ]
ask turtles [set energy energy - 1]
! n" s0 R# h' r2 A% lend
- k* a5 E8 \% H( t" K; C- A' k; f- P- L1 L/ \
|