Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive /   Program the game Battleship

  Program the game Battleship

Math

 

Program the game Battleship. The rough steps for this are as follows: A) Load the ship data file for the human and computer players ships( I cannot upload .m file here. Please provide an email so that I could send that to you)

B) Use a nested loop structure that iterates between the human and computer player until the right number of

hits is achieved for either player

C) Use the following functions to keep your code modular

a. A function to plot the playing field and ships

b. A function to get the input from the human

i. This function should get two values from the human, a letter and a number. Perform data checking and correction (for lower case letters) such that it repeats until the user enters two valid choices.

c. A function for the computer's selection that randomly guesses a space that has yet to be selected by it.

d. A function to compare the player selection (human or computer) to the appropriate

map

e. A function to plot the hits and misses as appropriate.

D) Be sure to show the computer's ships as shown. Yes, this is "cheating" but makes grading much easier.

Hints:

• For the playing field, the field itself is 1-10, but to make it look right, you need

to plot 0 to 11.

• Play around with the label properties using set(gca,'YTickLabels',{<labels>} to get the letters right.

• To easily iterate between the human and computer maps, consider using another dimension...

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE