请问:- \ j U$ C! e8 S; C
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
7 p D/ b9 E7 ^; d* ^% M: s+ c8 b( W+ ? N. E
7 U* v3 i ?0 ?
turtles-own [ energy ]
' _. i @" _" U6 u$ z) r! bto setup: q* D. f" s9 O7 w0 [
clear-all
/ q2 @$ z B9 ^8 e8 A( u5 L; uset-default-shape turtles "square"
8 e4 H z; m! S" O2 hcrt nutrition
* h; {: x! x% S: ^- task turtles[
5 _5 K! S8 O0 i# S$ G set color white
. n# w+ e7 j# A setxy random-pxcor random-pycor]
% t. }* h8 m& o! Z" P
1 N" I' V8 u. W& hask n-of microbes-initialization patches; F9 x- i! A, ? z! w. y
[ set pcolor green]9 }. z) J, F' o! M2 J6 e
ask turtles [set energy 1]
) Z" W' c/ H7 W' Hend
/ e; c5 Y" z @) Q1 _- ?8 w- F' q N6 c; |, @" R
to go5 z) r6 p) E6 v- i" A9 s
ask turtles [set heading 90 * random 4 fd 1]
( C. {, C1 J: [5 U [ ask patches with [ any? turtles-here]
5 s4 Q/ j1 t. ^3 C; H4 b$ b- } [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% b7 F6 U# j$ p" \4 f/ ]' _4 `: w+ h
ask turtles [ if energy = 0 [die ]]
; D5 s5 h; G; e4 \ end$ i3 h/ I2 j/ V) I/ E6 B
4 ^- T- c* F& O
to tt
! i, Z% [% ?( b; K7 Qask patches [set pcolor gray ]
; Z' u; W$ g* P0 }' A4 w0 T& Vask turtles [set energy energy - 1]
: r3 ^& Z, E( j% J8 M rend
! M: U$ w3 ?- L" I: b8 B2 K3 t u9 o) J5 s: ^; x
|