Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NetLogo:为什么事件只发生在离散的滴答声?_Netlogo_A Star - Fatal编程技术网

NetLogo:为什么事件只发生在离散的滴答声?

NetLogo:为什么事件只发生在离散的滴答声?,netlogo,a-star,Netlogo,A Star,简单地说,这里我有一个离散的t-列表,对应于每个代理人员的坐标x-列表和y-列表 if ticks = first t-list 生成新人员并找到他们,仅当人员id不在现有人员id列表中时才能创建新人员 if ticks > first t-list 移动到下一个位置,同时检查下一个位置是否与当前位置不同,代码如下 to go ask persons [ ifelse ( not empty? t-list )[ if ( ticks = first t-li

简单地说,这里我有一个离散的t-列表,对应于每个代理人员的坐标x-列表和y-列表

if ticks = first t-list
生成新人员并找到他们,仅当人员id不在现有人员id列表中时才能创建新人员

if ticks > first t-list
移动到下一个位置,同时检查下一个位置是否与当前位置不同,代码如下

to go
  ask persons [
    ifelse ( not empty? t-list )[ 
      if ( ticks = first t-list )[
        new-locate-persons
      ]
      if ( ticks > first t-list ) [
        move-to-nextlocations
      ]   
    ]
    [ stop ]
  ]          
  tick
end
对于移动到nextlocations,我要求person按照GitHub中的a-star-nlogo扩展生成的移动路径移动链接

用法是

a-star-nlogo:a-star-search<Turtle><TurtleSet> - return:PatchList
a-star-nlogo:a-star-search<Turtle><TurtleSet><TurtleSet> - return:PatchList

问题是,我发现移动只发生在离散的滴答声,例如t-list类似于[6 12 18 24],新代理在滴答声6生成,当滴答声在7,8,9,10,11时,它们不会移动,人们只是在滴答声12,18,24时突然移动,无论路径规划问题如何。我认为围棋中出现了一些问题,并定义了运动条件部分。但是,我没有任何线索!有人能帮我吗?非常感谢

正如我在评论中所说,我修改了移动到下一个位置的部分,现在看起来:

to generate-nextlocation
  ask patch-at ( item 1 x-list ) ( item 1 y-list) [ sprout-nextlocations 1  [set color black ]]
end 

to move-to-nextlocation
let targets nextlocations

set move-path a-star-nlogo:a-star-search-with-multiple-turtle-avoidance  self targets walls
 if ( empty? move-path )[
 show "no way out"]
 while [ not empty? move-path ][
 let next-step first move-path
 set move-path but-first move-path
 move-to next-step
 pd
] 
end

但它仍然只在t列表中的刻度上移动,与速度设置无关。所以我想解决这个问题的方法可能是

由于计划路径返回到(pxcor,pycor)的路径列表,我将打印每个人的路径列表并生成新的填充。然后在t-list中填写遗漏的记号,读取此文件,重新定位它们,并从列表中删除历史位置。如果我将滴答声间隔定义得足够小,它可能看起来更平滑


这不是一个聪明的方法,如果有人有更好的解决方案,请与我们分享!非常感谢

第一个代码块在语法上不正确。它不会编译。我认为NetLogo中没有你所拥有的东西。你需要纠正它。我无法确定逻辑中是否存在导致您观察到的问题的错误,因为代码没有意义。我注意到它不应该是第二个,如果前面有else(勾选=第一个t-list)。我修改了它。问题是,当运行tick与t-list的数量相等时,它运行得相当慢,代理生成或移动,当运行tick与t-list中不存在的tick相等时,它运行得非常快,并且没有代理在该tick中移动OK,现在
go
例程看起来正常。它应该在
t-list
中的勾号上调用
new locate persons
,并在大多数勾号上调用
move to nextlocations
。这是假设任何时候
t-list
中的内容都是您所期望的。(我想您正在从
t-list
的某个地方删除元素。)您确定
移动到下一个位置会导致移动吗?你能在提示符下运行它,看看会发生什么吗?在
move to nextlocations
new locate persons
中插入
print
语句也可能很有用,以确保他们在您思考的时候运行并且具有正确的值。谢谢,Mars。这是真的,在这个点位于这个t列表之后,我将从列表中删除它,删除历史点。我修改了移动到下一个位置的部分,现在可以运行了。我会看看我是否可以上传运行界面以后。我有一个如何解决这个问题的想法。你,这看起来应该是对原来问题的编辑,或者是一个新问题。(我很高兴我的其他评论很有帮助。)
to generate-nextlocation
  ask patch-at ( item 1 x-list ) ( item 1 y-list) [ sprout-nextlocations 1  [set color black ]]
end 

to move-to-nextlocation
let targets nextlocations

set move-path a-star-nlogo:a-star-search-with-multiple-turtle-avoidance  self targets walls
 if ( empty? move-path )[
 show "no way out"]
 while [ not empty? move-path ][
 let next-step first move-path
 set move-path but-first move-path
 move-to next-step
 pd
] 
end