Create a more advanced Battleship game.
- 2D Arrays
Modify your Battleship game so that the board size, ship size, and number of guesses are determined by the player.
Your game needs to be designed with the following rules.
- Game Board Size
- Ask the user for the height and width of the board.
- Your code should be able to handle a non-square board.
- Because the console is limited in size, we will only test boards up to 20×20.
- Ship Size
- Let the user choose the size of the ship.
- Check to make sure the user does not choose a ship that won’t fit on the board.
- Ship Placement
- Placement of the ship should still be random.
- Ship must be placed fully on the board.
- Allow for the ship to be placed diagonally.
- Choose a random X and Y position for ship (or the first square of the ship).
- Choose another random number for the direction of the ship (N, NE, E, SE, S,…)
- Check to make sure the ship will fit in the (X,Y) position and direction. If it doesn’t, choose a different position and/or direction.
- Let the user determine the number of guesses.
- Don’t let the number of guesses be more than the number of spots on the board.
- Do simple error checking to make sure an out-of-bounds guess doesn’t crash your game.
Edhesive Term 1
Edhesive T1 Lesson 25: Algorithms
AP College Board 6.4: Algorithms using arrays