Battleship Game

Requirements:

  1. Support a menu.
  2. Play a new game. (Overwrite save file with default state/values).
  3. Load game.
  4. Quit.
  • Support two (human) players on the same console (aka the cli command line console). Player vs player. No computer. No need to implement single player mode.
  • No need to hide each players maps, print both players map on the output.
  • During each player’s turn print their statistics and state of each of their ship.
  • Mini-menu: Give player the choice to ‘Fire’, ‘Save’, ‘Quit’.
  • On map, use ‘~’ as water, ‘M’ as misses, ‘H’ as hits.
  • Support dynamically sized maps using heap memory
  • Implement the maps as a dynamically generated 2D array (hint: malloc or calloc)
  • Randomly generated map size (hint; rand srand)
  • Keep the random map size between 10×10 to 50×50. No need to overkill.
  • Nothing fancy for printing a map, use ascii art.

EXAMPLE

Battleship Game
  • Players manually place their ships on the map.
  • Choose orientation of each ship.
  • Place ship on map by asking player to choose a coordinate on the map. The program will automatically do the rest (left to right if horizontal or up to down if vertical).
  • Ships must be within bounds of the map.
  • Must not overlap each other.
  • Program must run with a save file (like save.txt or save.log). This file is use to save or load the game.
  • Support saving a game.
  • Each player’s statistics (hits, misses, state of each ship (either sunk, number times hit)
  • Each player’s map.
  • Support loading a saved game and continuing from there.
  • Game is turn based. Each player takes a turn until a winner or someone quits.
  • No third-party header files/libraries. Use the standard libraries for C.

One of each ship must be placed on the map:

  1. Patrol Boat (2 Length) On map represent as ‘P’.
  2. Aircraft Carrier (5 Length) On map represent as ‘A’
  3. Battleship (4 Length) On map represent as ‘B’
  4. Destroyer (3 Length) On map represent as ‘D’
  5. Submarine (2 Length) On map represent as ‘S’
  6. Cruiser 3 (Length) On map represent as ‘C’
Subscribe For Latest Updates
Let us notify you each time there is a new assignment, book recommendation, assignment resource, or free essay and updates