private static void TestHolder() { s = new StateEngine(@"../../output/Tests/Test/state.json"); string move = s.TryDodge(); Console.WriteLine("Dodge: " + move); move = s.TryShoot(); Console.WriteLine("Shoot: " + move); move = s.TryBuild(); Console.WriteLine("Build: " + move); move = s.TryPlace(); Console.WriteLine("Place: " + move); move = s.TryShift(); Console.WriteLine("Shift: " + move); }
private static void TestPlacing() { s = new StateEngine(@"../../output/Tests/TryPlaceNoBlockages/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no need (Expected: null) - " + result); if (result != null) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceInFrontOfMC/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, standing in front of missilecontroller (Expected: not null) - " + result); if (result == null) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceLeftBest/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on two left blocks (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceRightBest/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on two right blocks (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceLeftGood/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on 1 left block (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceLeftBestLeftTwoBlocked/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, left is best, bullet on 2nd left row (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondNotDangerous/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shield on 2nd right row (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondDangerous/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but missile and shields in the way. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceInMiddleShieldsLeftRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above. (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceInMiddleShieldsLeftRightanotherRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceAtRightShieldsLeftRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); // Weird situation. No point moving right because we'd never really reach an opening s = new StateEngine(@"../../output/Tests/TryPlaceAtRightShieldsLeftRightAnotherLeftWallAtRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the left. Can't really move right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondDangerousLeftBlocked/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but missile and shields in the way, left is blocked. (Expected: null) - " + result); if (result != null) Debugger.Break(); s = new StateEngine(@"../../output/Tests/TryPlaceNowhereForAWhile/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but lots of shields for a long way. (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) Debugger.Break(); }
private static void TestPlacing() { s = new StateEngine(@"../../output/Tests/TryPlaceNoBlockages/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no need (Expected: null) - " + result); if (result != null) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceInFrontOfMC/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, standing in front of missilecontroller (Expected: not null) - " + result); if (result == null) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceLeftBest/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on two left blocks (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceRightBest/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on two right blocks (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceLeftGood/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, no blockages on 1 left block (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceLeftBestLeftTwoBlocked/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, left is best, bullet on 2nd left row (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondNotDangerous/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shield on 2nd right row (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondDangerous/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but missile and shields in the way. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceInMiddleShieldsLeftRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above. (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceInMiddleShieldsLeftRightanotherRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceAtRightShieldsLeftRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } // Weird situation. No point moving right because we'd never really reach an opening s = new StateEngine(@"../../output/Tests/TryPlaceAtRightShieldsLeftRightAnotherLeftWallAtRight/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, shields are above and another on the left. Can't really move right. (Expected: MoveLeft) - " + result); if (!result.Equals(CharonBot.Moves.MoveLeft.ToString())) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceRightBestSecondDangerousLeftBlocked/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but missile and shields in the way, left is blocked. (Expected: null) - " + result); if (result != null) { Debugger.Break(); } s = new StateEngine(@"../../output/Tests/TryPlaceNowhereForAWhile/state.json"); result = s.TryPlace(); Console.WriteLine("Tried placing ship, right is best, but lots of shields for a long way. (Expected: MoveRight) - " + result); if (!result.Equals(CharonBot.Moves.MoveRight.ToString())) { Debugger.Break(); } }