You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Meta: Not a bug, per se. Not a feature request. Should this go in "Discussions"?
I'm looking at HexGrid and Hex. Hex carries around a lot of state. One part of the state is f, g, h, pathparent used by pathfinding.
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 heuristic h. From Wikipedia:
A* achieves better performance by using heuristics to guide its search.
But pathfinding.js doesn't actually use h, 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 on Hex leads to tightly coupled modules, and extra operations in pathfinding, Hex, and HexGrid to keep those attributes "clean".
On top of that, forcing callers to provide concrete Hexs, a concrete HexGrid, 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.
The text was updated successfully, but these errors were encountered:
HexGrid calls search in pathfinding.ts, but always with coordinates that don't exist in-game – (-2,-2). This essentially runs a shortest path tree algorithm. The algorithm is used to set the value of Hex.g, the cost of the path to get to a particular Hex. Hexs with a g below a certain threshold are then collected into an array and returned.
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.
The text was updated successfully, but these errors were encountered: