我正在创建一个关于动物园的Netlogo模型。我需要我的动物园客人(多只乌龟)沿着一条环形路径开始,每隔24个蜱虫在动物园入口处开始(我的模型中有1个小时是1小时)。它必须移动笼养动物的笼子,因为我无法让我的客人进入动物区域。路径不必是快速或最短的,我只需要乌龟不要偏离它。我宁愿不使用GIS来创建一条路径。
我的世界尺寸在两个方向都是-30到30并且不会环绕。
笼子的下落描述如下:
patches-own [ tigerhabitat?
flamingohabitat?
monkeyhabitat?
hippohabitat?
giraffehabitat?
]
to create-habitats
ask patches with [ pxcor < -12 and pycor > 23 ]
[ set tigerhabitat? true
set pcolor green ]
ask patches with [ pxcor > 20 and pycor > 20 ]
[ set hippohabitat? true
set pcolor blue ]
ask patches with [ pxcor > 18 and pycor < 15 and -1 < pycor ]
[ set flamingohabitat? true
set pcolor 96 ]
ask patches with [ pxcor > -10 and pxcor < 10 and pycor < 10 and -10 < pycor ]
[ set monkeyhabitat? true
set pcolor green ]
ask patches with [ pxcor < -12 and pycor < -20 ]
[ set giraffehabitat? true
set pcolor 67 ]
end
答案 0 :(得分:1)
to setup
ca
reset-ticks
crt 10 [
setxy -25 0
]
create-habitats
end
to go
exclude-cage-walk
tick
end
to exclude-cage-walk
ask turtles [
rt random 30 - 15
let target one-of patches in-cone 1.5 180 with [ pcolor = black ]
if target != nobody [
face target
move-to target
]
]
end
你可以看到,在前进之前,每只乌龟评估它选择的move-to
补丁是否为黑色,如果它不黑色,乌龟将不会移动那里。当然,你必须修改它以满足你的需要,并让乌龟走在一个单向的循环,但这是一个约束龟运动的简单方法。