设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6793|回复: 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吧 可能差不多2 _" l; |' C$ c" f
/ e9 ]* f! x- \# f- Q; w+ S! _
turtles-own[g h]4 Y2 }9 q8 n0 m& |
to setup; h: D, U! Q0 J
  ca 1 L" f: }. k) N7 R" x) m4 M  M
  crt 50[set shape "circle" setxy random-xcor random-ycor]9 E5 s1 O7 B7 E& R1 S
end
5 d9 c/ a$ _0 `2 L6 pto go7 a, n4 J! D8 z$ M) u" x0 Z9 g
  ask turtles [set g random-float 150
, i1 [4 M! X; \    set h random-float 50]
4 M9 O* a* B, }5 P/ c  ' v, z2 O: m! d6 W8 |
  
8 M# X, |0 E$ R( C& W  ask turtles " j7 U7 e4 U! Y+ p2 z5 j  S; |: n5 P
  [ifelse max-one-of turtles-on neighbors [g] != nobody# J- z! B7 ~% R
    2 L& T. B& H- D
  [set h [h] of max-one-of turtles-on neighbors [g]]  {, y1 c8 u, z& h" G( K
  [set h [h] of self]
1 {& `$ `+ E+ e3 y- Y* ?3 J* f  % b# }2 k- H) |* D6 l
  ]5 B& _, U/ L$ n$ z9 W, ?8 l' Q
  
, @! S- z/ r. s! d3 a  end
7 |5 o( R1 D: L$ _类似这样的吧。

评分

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

查看全部评分

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

本版积分规则

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

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

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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