FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.64k stars 343 forks source link

`PathVertex::g_score` penalty for `astar.rs` #389

Closed Cordain closed 1 year ago

Cordain commented 1 year ago

Background

Current implementation of A* assumes, that all vertexes on the map have the same difficulty to reach them. This is not the case, when, for example, some RTS troops are traveling on different types of terrain, like grass, ice or sand. It would be nice to manipulate the "reachability" of vertexes.

Proposition

My idea of application of such modifier is to expand the formula of g_score calculation to include difficulty parameter stored in neighbor PathVertex object as a multiplier of distance between current vertex and neighbor. This can be used in dynamic changes of the environment, followed by rebuild of pathfinder.