设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6792|回复: 1

[求助] 请教starlogo的邻居在程序中怎么表示?感激不尽

[复制链接]
发表于 2009-7-13 18:19:36 | 显示全部楼层 |阅读模式
我现在正用starlogo做一个仿真。假设turtle有一个变量(比如:g),我想比较某个turtle的g 值和这个turtle的邻居(左右相邻的两个或某个)的g值大小,最后分别把g值最大的邻居turtle的一些属性变量赋给这个turtle.       我不能解决的问题是,不知道在starlogo中如何表示某个turtle的邻居,或者说在程序中如何提取到某个turtle的邻居的一些属性值,不知道这个程序代码如何写。
发表于 2010-5-9 21:45:16 | 显示全部楼层
用netlogo吧 可能差不多3 r7 A! B1 n) g, M

+ [: A0 y2 A, t* V; cturtles-own[g h]
) g; U+ T/ M1 [7 Eto setup
) _* i  G& g( y- I4 H2 S! X" X/ ~  ca
& g* j& `. x0 I+ H  crt 50[set shape "circle" setxy random-xcor random-ycor]: x1 h& \( M& u& D) k' Q
end
" ~7 o4 O1 w* w& s& B- ^' wto go+ \( d/ I4 B& H# f1 q# ?
  ask turtles [set g random-float 150  j/ M3 `" H- e
    set h random-float 50]
; Q. f: q, g  n$ |  
5 y! B2 m4 _* Q  
# j: V. D2 x! W  ask turtles
+ D8 R5 n+ s1 i9 M& f& D  [ifelse max-one-of turtles-on neighbors [g] != nobody4 t2 r! C! V8 Z/ l# V1 U! e
    9 \- k: [, A" V
  [set h [h] of max-one-of turtles-on neighbors [g]]
! `( A$ ^- u, R. V% t: M. U  [set h [h] of self]
. q  }' ]  D6 P! j, l7 H' I" A  2 h% W; I4 u; e/ O/ u+ c/ u
  ]  ]; f: M' \) W* m! |* J
  7 i4 @0 N% c$ s3 n$ j$ m# Q) m
  end5 c- w# y. p: d& u1 m' F& t/ l7 F& H
类似这样的吧。

评分

参与人数 1仿真币 +10 收起 理由
苘苘 + 10

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-16 20:45 , Processed in 0.013198 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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