public async System.Threading.Tasks.Task ExecuteTest_MapWithWalls_ActorAvoidWallsAsync() { // ARRANGE var map = await SquareMapFactory.CreateAsync(10); map.RemoveEdge(3, 3, 3, 4); map.RemoveEdge(3, 3, 2, 3); var expectedPath = new IMapNode[] { map.Nodes.Cast <HexNode>().SelectBy(4, 4), map.Nodes.Cast <HexNode>().SelectBy(3, 4), map.Nodes.Cast <HexNode>().SelectBy(2, 4), map.Nodes.Cast <HexNode>().SelectBy(1, 5), }; var startNode = expectedPath.First(); var finishNode = expectedPath.Last(); var actor = CreateActor(map, (HexNode)startNode); var task = new MoveTask(actor, finishNode, map); // ACT for (var step = 1; step < expectedPath.Length; step++) { task.Execute(); // ASSERT actor.Node.Should().Be(expectedPath[step]); } }
public async Task Run_GridGraphAndLinePath_PathFound() { // ARRAGE var map = await CreateGridOpenMapAsync(); var expectedPath = new IMapNode[] { map.Nodes.Cast <HexNode>().SelectBy(1, 1), map.Nodes.Cast <HexNode>().SelectBy(2, 2), map.Nodes.Cast <HexNode>().SelectBy(2, 3), map.Nodes.Cast <HexNode>().SelectBy(3, 4), map.Nodes.Cast <HexNode>().SelectBy(3, 5), map.Nodes.Cast <HexNode>().SelectBy(4, 6) }; var context = CreatePathFindingContext(); var astar = new AStar(map, context, expectedPath.First(), expectedPath.Last()); // ACT var factState = astar.Run(); // ASSERT factState.Should().Be(State.GoalFound); var factPath = astar.GetPath(); factPath.Should().BeEquivalentTo(expectedPath); }
public async System.Threading.Tasks.Task ExecuteTest_FindingPathAndMove_IsCompleteTrueAsync() { // ARRANGE var map = await SquareMapFactory.CreateAsync(10); var expectedPath = new IMapNode[] { map.Nodes.Cast <HexNode>().SelectBy(4, 4), map.Nodes.Cast <HexNode>().SelectBy(3, 4), map.Nodes.Cast <HexNode>().SelectBy(2, 4), map.Nodes.Cast <HexNode>().SelectBy(1, 5), }; var startNode = expectedPath.First(); var finishNode = expectedPath.Last(); var actor = CreateActor(map, (HexNode)startNode); var task = new MoveTask(actor, finishNode, map); // ACT for (var step = 1; step < expectedPath.Length; step++) { task.Execute(); } // ASSERT task.IsComplete.Should().BeTrue(); }
public async Task Run_CheckNeighborBypass_ExpectedPath() { // ARRAGE var map = await CreateGridOpenMapAsync(); var expectedPath = new IMapNode[] { map.Nodes.OfType <HexNode>().SelectBy(1, 1), map.Nodes.OfType <HexNode>().SelectBy(2, 2), map.Nodes.OfType <HexNode>().SelectBy(2, 3), map.Nodes.OfType <HexNode>().SelectBy(3, 3), map.Nodes.OfType <HexNode>().SelectBy(4, 3), map.Nodes.OfType <HexNode>().SelectBy(5, 3), }; var context = CreatePathFindingContext(); var astar = new AStar(map, context, expectedPath.First(), expectedPath.Last()); // ACT var factState = astar.Run(); // ASSERT factState.Should().Be(State.GoalFound); var factPath = astar.GetPath(); factPath.Should().BeEquivalentTo(expectedPath); }