amethyst / amethyst/bracket-lib

Dijkstra map should set starting depths before iterating neighbors

未关闭
#370 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
1.7k
派生
126
PR 合并指标
30 天内没有已合并 PR

描述

Thanks for the roguelike tutorial, it was a great way to get started with rust. I've been playing around with it and noticed the DijkstraMap is not quite working like I would expect.

In the DijkstraMap build function although the start tiles are [assigned 0 depth in the `open_list` queue](https://github.com/amethyst/bracket-lib/blob/master/bracket-pathfinding/src/dijkstra.rs#L153), the [depth only gets written to `dm.map` when iterating exits](https://github.com/amethyst/bracket-lib/blob/master/bracket-pathfinding/src/dijkstra.rs#L167). The effect is that a start tile's own value only gets set when iterating an adjacent tile's exits, at which point `new_depth` is 1. The start tiles then appear to have the same depth as their adjacent tiles. This is a problem for using `find_lowest_exit` to path all the way to a start tile, as the gradient disappears before actually reaching it.

For example in this image the grayscale tiles are starts and the green tiles show the distance to the gray tiles. Trying to path out of the green and into the gray tiles is unreliable because the gray exits have the same depth as some of the green exits:
![Image](https://github.com/user-attachments/assets/a35ae5f6-93d1-425e-ab40-c357f98bfee4)

Looks like the other build variations have the same issue.

I think when you push the starts into `open_list` you should also set `dm.map[*start] = 0.0;` (or the provided depth for the weighted build). Trying that gives the result I'd expect:
![Image](https://github.com/user-attachments/assets/d14f71da-53b7-47f5-a03d-ecd5f268333b)

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。