-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented support for weighted paths
- Loading branch information
val antonini
committed
Apr 25, 2024
1 parent
c47d2b6
commit 5968008
Showing
10 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using AStar.Options; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace AStar.Tests | ||
{ | ||
[TestFixture] | ||
public class WeightedPathingTests | ||
{ | ||
[Test] | ||
public void ShouldPathWithWeight() | ||
{ | ||
var level = @"1111115 | ||
1511151 | ||
1155511 | ||
1111111"; | ||
var world = Helper.ConvertStringToPathfinderGrid(level); | ||
var opts = new PathFinderOptions { Weighting = Weighting.Positive }; | ||
var pathfinder = new PathFinder(world, opts); | ||
|
||
var path = pathfinder.FindPath(new Position(1, 1), new Position(1, 5)); | ||
|
||
path.ShouldBe(new[] { | ||
new Position(1, 1), | ||
new Position(2, 2), | ||
new Position(2, 3), | ||
new Position(2, 4), | ||
new Position(1, 5), | ||
}); | ||
} | ||
|
||
[Test] | ||
public void ShouldPathWithInvertedWeight() | ||
{ | ||
var level = @"9999995 | ||
9599959 | ||
9955599 | ||
9999999"; | ||
|
||
var world = Helper.ConvertStringToPathfinderGrid(level); | ||
var opts = new PathFinderOptions { Weighting = Weighting.Negative }; | ||
var pathfinder = new PathFinder(world, opts); | ||
|
||
var path = pathfinder.FindPath(new Position(1, 1), new Position(1, 5)); | ||
|
||
path.ShouldBe(new[] { | ||
new Position(1, 1), | ||
new Position(2, 2), | ||
new Position(2, 3), | ||
new Position(2, 4), | ||
new Position(1, 5), | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters