static void AddShipOnBoard(Battleship ship, Player player) { for (int i = 0; i < ship.Size; i++) { player.board[ship.CurrentX, ship.CurrentY] = ship.signature; switch (ship.Direction) { case 'r': ship.y++; break; case 'd': ship.x++; break; case 'l': ship.y--; break; case 'u': ship.x--; break; default: break; } } }
private void SetShip(int location, Battleship ship, Player player) { if (player.IsHuman()) { Button button = GetButtonFor(location); button.BackColor = Color.Red; } ship.SetLocation(location); }
static Battleship MakeShipAI(string rank, int size, Player player, char sign) { // Create an object of class Battleship for the AI Random rnd = new Random(); int coordinatesX = rnd.Next(0,10); int coordinatesY = rnd.Next(0, 10); int intDirection = rnd.Next(1, 5); char direction = ' '; switch (intDirection) { case 1: direction = 'r'; break; case 2: direction = 'd'; break; case 3: direction = 'l'; break; case 4: direction = 'u'; break; default: break; } string aiCoordinates = coordinatesX.ToString() + coordinatesY.ToString(); bool validPosition = ValidatePositionAI(aiCoordinates, size, direction, player); while (validPosition == false) { coordinatesX = rnd.Next(0,10); coordinatesY = rnd.Next(0, 10); intDirection = rnd.Next(1, 5); direction = ' '; switch (intDirection) { case 1: direction = 'r'; break; case 2: direction = 'd'; break; case 3: direction = 'l'; break; case 4: direction = 'u'; break; default: break; } aiCoordinates = coordinatesX.ToString() +coordinatesY.ToString(); validPosition = ValidatePositionAI(aiCoordinates, size, direction, player); } Battleship ship = new Battleship(rank, coordinatesX, coordinatesY, size, direction, sign); return ship; }
static Battleship CreateShip(string input, string rank, int size, Player player, char sign) { // Create an object of class Battleship for the given player int coordinatesX = ConvertToInt(input[0].ToString()); int coordinatesY = int.Parse(input[1].ToString()); Battleship ship = new Battleship(rank, coordinatesX, coordinatesY, size, input[2], sign); return ship; }
static void TestBattleship(string sBenchmarkPath, int iSize) { SDRPlanner.AddAllKnownToGiven = true; Battleship bs = new Battleship(iSize * 10); string sBenchmark = bs.Name; bs.WriteDomain(sBenchmarkPath + sBenchmark); bs.WriteProblem(sBenchmarkPath + sBenchmark); SDRPlanner.TagsCount = 2; SDRPlanner.AddTagRefutationToGoal = false; //BeliefState.AddAllKnownToGiven = true; //TestCLG(sBenchmarkPath + sBenchmark + "\\", 2); TestBenchmark(sBenchmarkPath, sBenchmark, 25, true, false); }