请问:0 K2 T/ Q3 \ d, R" X$ K2 E
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 F0 x) x+ m$ z2 Y; D5 o
9 g7 Q9 p6 u( J6 V- [2 D3 Q* @; Y3 u1 B
4 _5 c- Y% r3 x- ]: Hturtles-own [ energy ]
/ T' Y. r: C& u" rto setup( \! T5 c1 h+ G5 V" G
clear-all
% x5 ?* c) U1 X! p4 nset-default-shape turtles "square"$ F& B4 R+ f% c4 I2 E
crt nutrition- E5 }" V% q$ M+ i* H9 L
ask turtles[
* _4 S6 W& l' @1 X* w set color white; ^- K! _2 S% v! m: s
setxy random-pxcor random-pycor]$ { S, ^6 b3 Y5 k w3 K, }. T
) q0 d" Z8 y& n; u7 o( X
ask n-of microbes-initialization patches+ q* Y5 r, O B2 H! x
[ set pcolor green] a9 i S/ q% |& k* E8 A9 O2 j0 T
ask turtles [set energy 1]
, @" |+ ? c/ _ N; jend& W( n& T# u4 m1 `0 f
+ O' W2 S- G0 s
to go
" S8 L) s6 i' V8 i6 f" D ~ ask turtles [set heading 90 * random 4 fd 1]' m6 i+ ~3 P4 R
ask patches with [ any? turtles-here]# @# s8 Z. V! `! `
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]" t; \) M: U' }; a
ask turtles [ if energy = 0 [die ]]0 _2 W) n3 h8 V1 T9 \) G; K
end7 m5 e5 V4 @) ^0 E
, @0 v, P2 k+ N& d! `5 M
to tt
( g$ w8 d4 z$ P, ?ask patches [set pcolor gray ]/ L! ^8 p# I; J4 T
ask turtles [set energy energy - 1]
) ]+ w) I5 l7 b+ Lend8 Z- U' R- o* G1 v% ?
0 M) m; i6 x/ {2 k0 Z9 x9 u |