设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8750|回复: 1

[求助] turtle粘合patch的运动问题

[复制链接]
发表于 2008-4-8 10:49:43 | 显示全部楼层 |阅读模式
5仿真币
请问:- \  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
 楼主| 发表于 2008-4-9 10:47:16 | 显示全部楼层
谢谢楼上两位,后来自己用两种turtle来表示暂时把问题解决了,以后再出现难题再向你们请教啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-5-1 00:53 , Processed in 0.012603 second(s), 11 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表