diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-07-06 13:31:37 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-07-06 13:31:37 -0400 |
commit | 23dbe100fb468c6268a94bcb3c448948fd686d62 (patch) | |
tree | 5c2f272b9e6aea9ee2874b65855819a09835d0a1 /src/party.cpp | |
parent | cb1421b91b2f8ffa71f7ee009dad4e237ed36e2c (diff) | |
download | tanetane-23dbe100fb468c6268a94bcb3c448948fd686d62.tar.gz tanetane-23dbe100fb468c6268a94bcb3c448948fd686d62.tar.bz2 tanetane-23dbe100fb468c6268a94bcb3c448948fd686d62.zip |
Improved eight-direction pathfinding
In the past, not using the "cardinal directions only" flag resulted in awkward and unintuitive paths. Two changes were made to the algorithm to improve these paths. One, nodes in the graph are now a pair of a position and the direction taken to get there. This way, a small penalty can be applied whenever a turn is taken, which should incentivise paths with fewer turns (which should be simpler). This change theoretically affects the cardinal mode as well, but in practice it is unlikely to change the paths that would've been generated. This also multiplies the search space by eight (four in cardinal mode), but so far it does not appear to be a significant resource drain. Two, the heuristic used in eight-directions mode is now octile distance, instead of dominant axis distance. Additionally, the real cost of moving diagonally is ~sqrt(2) instead of 1. This somewhat disincentivises diagonal movement, since it is no longer considered the same as cardinal movement (even though cardinal and diagonal movement occurs at the same speed), but the turning penalty makes moving diagonally more favourable than zigzagging cardinally to reach a diagonal destination. Most scripted movement in the game is likely to use cardinal mode because that mirrors the way most scripted movement in Mother 3 works, but in some cases (the Hinawa event on the cliff) diagonal movement just looks better, and thus it's useful to have the improved pathfinding algorithm.
Diffstat (limited to 'src/party.cpp')
0 files changed, 0 insertions, 0 deletions