Pathfinding doesn't use h(n) #2462
Replies: 2 comments
-
Documenting things here:
|
Beta Was this translation helpful? Give feedback.
-
Sounds like a good rewrite, nice find! I've converted this to discussion more for the sake of testing the GitHub feature tbh. 🐻 |
Beta Was this translation helpful? Give feedback.
-
Meta: Not a bug, per se. Not a feature request. Should this go in "Discussions"?
I'm looking at
HexGrid
andHex
.Hex
carries around a lot of state. One part of the state isf
,g
,h
,pathparent
used bypathfinding
.The path finding algo setup is similar to A*. It's got a a small twist for
Creature
size. The benefit of using A* over another algo (e.g., Djikstra) comes from the use of the heuristich
. From Wikipedia:But
pathfinding.js
doesn't actually useh
, except to set it to 0. Here's an example for a very brief game (2 rounds, summoning 2 creatures and moving each creature):~6,000 assignments setting
h
to 0.Ultimately, 6,000 unused assignments don't matter unless performance is affected.
But the keeping
f
,g
,h
onHex
leads to tightly coupled modules, and extra operations inpathfinding
,Hex
, andHexGrid
to keep those attributes "clean".On top of that, forcing callers to provide concrete
Hex
s, a concreteHexGrid
, and a creature id isn't ultimately necessary and makes the algo resistant to testing.So ...
So, I'm going to go ahead and work on a full rewrite here, unless there are objections.
Beta Was this translation helpful? Give feedback.
All reactions