我刚刚开始在网络徽标中创建一个基于代理的模型。我有两个形状文件,我想让我的海龟在我的网络地图上移动。目前,我只能在我的模型中加载shapefiles。有人能告诉我如何在我的网络地图上移动乌龟吗?
到目前为止,我的代码如下:
extensions [gis]
breed [cars car]
turtles-own [destination]
globals [
states-dataset
car-blue]
to custom-clear
reset-ticks
clear-turtles
clear-patches
clear-drawing
clear-all-plots
end
to setup
clear-all
custom-clear
ask patches [set pcolor green - 3]
set states-dataset gis:load-dataset "C:/Users/ADMIN/Documents/QGIS/Export Netlogo/Format .shp/state.shp"
gis:set-world-envelope gis:envelope-of states-dataset
gis:set-drawing-color yellow
gis:draw states-dataset 1
set route-car-blue gis:load-dataset "C:/Users/ADMIN/Desktop/routefiles/Shapefile/car/route-car-blue.shp"
gis:set-drawing-color blue
gis:draw angkot-permatabiru 1.5
foreach gis:feature-list-of route-car-blue
[car-pb -> let location gis:location-of gis:centroid-of car-pb
create-turtles 5 [
set xcor item 0 location
set ycor item 1 location
set shape "car"
set size 1
]]
end
to go
ask turtles [
let new-location one-of [link-neighbors] of destination
move-to new-location
set destination new-location]
tick
end有人知道怎么修改我的密码吗?我想让我的海龟移动基于我的网络地图。
发布于 2022-11-02 08:41:58
问题可能在于destination和new-location的循环性。您将new-location定义为destination的link-neighbor,但是由于还没有destination,所以这个new-location设置为nobody。然后,将您的destination设置为您的new-location,这也将destination设置为无人,最终形成一个没有任何运动发生的圆圈。
解决这个问题的方法是在destination期间为每个海龟定义一个setup。
https://stackoverflow.com/questions/74282679
复制相似问题