Pathfinding doesn't use h(n) #2462
andretchen0
started this conversation in
Ideas
Replies: 2 comments
|
Documenting things here:
|
0 replies
|
Sounds like a good rewrite, nice find! I've converted this to discussion more for the sake of testing the GitHub feature tbh. 🐻 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Meta: Not a bug, per se. Not a feature request. Should this go in "Discussions"?
I'm looking at
HexGridandHex.Hexcarries around a lot of state. One part of the state isf,g,h,pathparentused bypathfinding.The path finding algo setup is similar to A*. It's got a a small twist for
Creaturesize. The benefit of using A* over another algo (e.g., Djikstra) comes from the use of the heuristich. From Wikipedia:But
pathfinding.jsdoesn'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
hto 0.Ultimately, 6,000 unused assignments don't matter unless performance is affected.
But the keeping
f,g,honHexleads to tightly coupled modules, and extra operations inpathfinding,Hex, andHexGridto keep those attributes "clean".On top of that, forcing callers to provide concrete
Hexs, 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.
All reactions