Skip to content

Commit

Permalink
Modify A* heuristic function to take into account if there's a star i…
Browse files Browse the repository at this point in the history
…n the new node, although it doesn't seem to make a difference
  • Loading branch information
eduherminio committed Dec 23, 2019
1 parent cd9739e commit 24e0513
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions AoC_2019/Problem18.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 533,18 @@ private static int AStarAlgorithmStoringNodes(List<LocationPoint> emptyLocations

private static int EstimateCost(Path pathIncludingCandidate, int keysToCollect)
{
return keysToCollect - pathIncludingCandidate.Moments.Last().Keys.Count;
return EstimateCost(pathIncludingCandidate.Moments.Last(), keysToCollect);
}

private static int EstimateCost(Moment moment, int keysToCollect)
{
return keysToCollect - moment.Keys.Count;
int newKeysFound = 0;
if (moment.Point.ContentType == ContentType.Key && !moment.Keys.Contains(moment.Point.Content))
{
newKeysFound = 1;
}

return keysToCollect - moment.Keys.Count - newKeysFound;
}

private static Func<LocationPoint, bool> MovementCandidateCondition(Moment currentMoment, Path currentPath)
Expand Down

0 comments on commit 24e0513

Please sign in to comment.