Netlogo 如何在六边形网格上的邻居之间移动海龟?
我想问一下如何把海龟搬到他们的邻居家。(房屋为六角单元) 我试着去做,但给了我一个错误 ;;;;;;;;;;;;;建造房屋或六角格Netlogo 如何在六边形网格上的邻居之间移动海龟?,netlogo,Netlogo,我想问一下如何把海龟搬到他们的邻居家。(房屋为六角单元) 我试着去做,但给了我一个错误 ;;;;;;;;;;;;;建造房屋或六角格 to setup-cells set-default-shape cells "hex" ask patches [ sprout-cells 1 [ set color grey set size 1.2 ;; shift even columns down if pxcor mod 2 = 0 [ set ycor yc
to setup-cells
set-default-shape cells "hex"
ask patches
[ sprout-cells 1
[ set color grey
set size 1.2
;; shift even columns down
if pxcor mod 2 = 0
[ set ycor ycor - 0.5 ] ] ]
ask cells
[ ifelse pxcor mod 2 = 0
[ create-links-with cells-on patches at-points [[0 1] [1 0] [1 -1]] ]
[ create-links-with cells-on patches at-points [[0 1] [1 1] [1 0]] ] ]
ask links [ hide-link ]
end
));;;;;;我在他们的房子里放海龟
to setup-population
ask patches [
sprout 2
if pxcor mod 2 = 0
[ set ycor ycor - 0.5 ]]
end
我的问题是如何将这只乌龟移动到链接邻居
我试着这么做
to move
ask turtles[
if ( random-float 1) < 0.03 [
move-to one-of link-neighbors
fd 1 ]]
end
好问题。很遗憾,十六进制单元格示例(您似乎正在使用的代码示例)中没有介绍这一点。或者我们应该有一个单独的六角细胞和海龟的例子 首先,你应该为住在房子里的海龟制作一个单独的品种,这样你就可以将它们与细胞龟分开。假设你称他们为人:
breed [people person]
然后您应该将sprout 2
更改为sprout people 2
至于实现移动,您尝试的代码不起作用,因为人们没有链接邻居。正是这些细胞与邻居有联系
因此,不是:
move-to one-of link-neighbors
你必须写:
move-to [one-of link-neighbors] of one-of cells-here
如果你想让人们面对运动的方向,那么:
let target [one-of link-neighbors] of one-of cells-here
face target
move-to target
非常感谢您再次回复,您解决了我的问题。是的,我做的和模型库中的十六进制单元格一样。再次感谢
let target [one-of link-neighbors] of one-of cells-here
face target
move-to target