public void CreateWithParent() { var target = Vector.Create(10, 10); var location = Vector.Create(19, 10); var parent = LocationCandiate.Create( target, Vector.Create(20, 10)); var candidate = LocationCandiate .Create(target, location, parent.ToSome()); Assert.AreEqual(location, candidate.Location); Assert.AreEqual( 1 * LocationCandiate.DistanceMultiplier, candidate.CurrentCost); Assert.AreEqual( 9 * LocationCandiate.DistanceMultiplier, candidate.RemainingEstimatedCost); Assert.AreEqual( candidate.CurrentCost + candidate.RemainingEstimatedCost, candidate.OverallCost); Assert.IsTrue(candidate.Parent.HasValue); Assert.AreSame(parent, candidate.Parent.Value); }
public void CalculateMoveCostNoParent() { var location = Vector.Create(19, 10); var moveCost = LocationCandiate .CalculateMoveCost(Maybe <LocationCandiate> .None, location); Assert.AreEqual(0, moveCost); }
public void EstimateRemainingMoveCost() { var location1 = Vector.Create(10, 10); var location2 = Vector.Create(12, 15); Assert.AreEqual( 7 * LocationCandiate.DistanceMultiplier, LocationCandiate.EstimateRemainingMoveCost(location1, location2)); }
public void CalculateMoveCostFromParent() { var target = Vector.Create(10, 10); var location = Vector.Create(19, 10); var parent = LocationCandiate.Create( target, Vector.Create(20, 10)); var moveCost = LocationCandiate .CalculateMoveCost(parent.ToSome(), location); Assert.AreEqual(1 * LocationCandiate.DistanceMultiplier, moveCost); }
public void CreateNoParent() { var target = Vector.Create(10, 10); var location = Vector.Create(19, 10); var candidate = LocationCandiate.Create(target, location); Assert.AreEqual(location, candidate.Location); Assert.AreEqual(0, candidate.CurrentCost); Assert.AreEqual( 9 * LocationCandiate.DistanceMultiplier, candidate.RemainingEstimatedCost); Assert.AreEqual( candidate.CurrentCost + candidate.RemainingEstimatedCost, candidate.OverallCost); Assert.IsFalse(candidate.Parent.HasValue); }
public void BuildActorPath() { var target = Vector.Create(5, 5); var first = LocationCandiate.Create( target, target + (Directions.West * 2), Maybe <LocationCandiate> .None); var second = LocationCandiate.Create( target, target + Directions.West, first.ToSome()); var final = LocationCandiate.Create( target, target, second.ToSome()); var result = RouteFinder.BuildActorPath(final); Assert.AreEqual(target, result.End); AssertPath( new [] { target + Directions.West, target }, result.ToSome()); }