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
Describe the bug
When setting the initial values of tiles next to the starting point they're not assigned an open state which often leads to them being overriden other nearby tiles.
This is the code that initiates the costs at the starting point
// Add connecting nodes if traversable
if (node.Traversable)
{
// Calculate the Costs
node.CurrentCost = from.CurrentCost + from.DistanceTo(node) * node.TraversalCostMultiplier;
node.EstimatedCost = from.CurrentCost + node.DistanceTo(to);
// Enqueue
open.Enqueue(node);
}
And this is the code that iteratively sets the costs
// Adds a previously not "seen" node into the Queue
if (connected.State == NodeState.Unconsidered)
{
connected.Parent = current;
connected.CurrentCost =
current.CurrentCost + current.DistanceTo(connected) * connected.TraversalCostMultiplier;
connected.EstimatedCost = connected.CurrentCost + connected.DistanceTo(to);
connected.State = NodeState.Open;
queue.Enqueue(connected);
}
else if (current != connected)
{
// Updating the cost of the node if the current way is cheaper than the previous
var newCCost = current.CurrentCost + current.DistanceTo(connected);
var newTCost = newCCost + current.EstimatedCost;
if (newTCost < connected.TotalCost)
{
connected.Parent = current;
connected.CurrentCost = newCCost;
}
}
The solution is a one line fix, altough it also might make more sense to move both of those code snipets into a sningle function
node.State = NodeState.Open;
i was considering doing a pull request however i do not have the time to write tests for this to fit in wth the guidelnes(since astar does not have any to begin with)
To Reproduce
There's no tests so it's rather difficult as i've only discovered it myself when using the code as part of a bigger project
Expected behavior
The iterative code that sets the costs does NOT override costs of tiles if the cost is higher - which it does as seen in the snipped above UNLESS the tile is unconsidered at which point it assumes the cost is 0 and overrides the cost without checking. The issue here is that all initial tiles start out as unconsidered rather than as open.
Actual behavior
In scenarios where one of the corner nodes is evaluated first
The text was updated successfully, but these errors were encountered:
aye that's what i wanted to do originally but currently writting tests for this is a bit out of the scope for my schedule, so hopefully someone else will take over on the issue
Describe the bug
When setting the initial values of tiles next to the starting point they're not assigned an open state which often leads to them being overriden other nearby tiles.
This is the code that initiates the costs at the starting point
And this is the code that iteratively sets the costs
The solution is a one line fix, altough it also might make more sense to move both of those code snipets into a sningle function
node.State = NodeState.Open;
i was considering doing a pull request however i do not have the time to write tests for this to fit in wth the guidelnes(since astar does not have any to begin with)
To Reproduce
There's no tests so it's rather difficult as i've only discovered it myself when using the code as part of a bigger project
Expected behavior
The iterative code that sets the costs does NOT override costs of tiles if the cost is higher - which it does as seen in the snipped above UNLESS the tile is unconsidered at which point it assumes the cost is 0 and overrides the cost without checking. The issue here is that all initial tiles start out as unconsidered rather than as open.
Actual behavior
In scenarios where one of the corner nodes is evaluated first
The text was updated successfully, but these errors were encountered: