Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm really struggling with creating a Battleship game using MATLAB. These are the requirements for the game board: the board is a fixed 9x9 block

I'm really struggling with creating a Battleship game using MATLAB. These are the requirements for the game board: the board is a fixed 9x9 block of cells, up to 4 ships are placed (the user can choose the number of ships placed), each ship occupies a number of adjacent cells arranged either horizontally or vertically and each ship has different sizes (4, 3, 2, 1 - minimum of 3 cells if user picks only one ship), the ships cannot overlap, the user inputs a starting location/cell for each ship, using the starting location the program should randomly decide whether to place the ship horizontally or vertically and place the ship on the board (if the ship cannot be placed on the board at the starting location the program should ask the user for a new starting location). These are the requirements for playing the game: if the user guesses a cell occupied by a ship the program should indicate a hit but if not the location should be marked a miss, a ship is only sunk when all cells occupied by the ship have been hit, at the beginning of the game the user should choose between "Easy" "Medium" and "Hard" difficulty levels, each level has a corresponding number of missiles associated with it (Hard only has 29 missiles, Medium has 39 missiles, and Easy has 49 missiles), the game is played until the user runs out of missiles or until all ships have been destroyed. Included is a picture of a possible sample output. Thank you!image text in transcribed

The player can play the game until he is out of missiles or he has destroyed all the ships in the field Extra Credit : If you implement this in multi player version you would receive an extra credit Sample output: >>battleship Choose Number of Ships: 1 Choose Number of Players 1 Choose difficulty: Easy GAME STARTED** You have 49 Missiles Enter coordinates to hit:11 Miss you have 48 Missiles Enter coordinates to hit: 1 2 hit you have 47 Missiles Enter coordinates to hit:13 hit You destroyed a CRUISER you have 46 Missiles There are no ships left. You WON the battle Stats you have 46 Missiles left you won the game in 3 tries HAPPY PROGRAMMING!!! The player can play the game until he is out of missiles or he has destroyed all the ships in the field Extra Credit : If you implement this in multi player version you would receive an extra credit Sample output: >>battleship Choose Number of Ships: 1 Choose Number of Players 1 Choose difficulty: Easy GAME STARTED** You have 49 Missiles Enter coordinates to hit:11 Miss you have 48 Missiles Enter coordinates to hit: 1 2 hit you have 47 Missiles Enter coordinates to hit:13 hit You destroyed a CRUISER you have 46 Missiles There are no ships left. You WON the battle Stats you have 46 Missiles left you won the game in 3 tries HAPPY PROGRAMMING

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago

Question

to encourage a drive for change by developing new ideas;

Answered: 1 week ago

Question

4 What are the alternatives to the competences approach?

Answered: 1 week ago