Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function Name: battleship didn't win the game, mark player two's guess on player one's board. Repeat this process until the game is over (when there

image text in transcribed

Function Name: battleship didn't win the game, mark player two's guess on player one's board. Repeat this process until the game is over (when there are no O's remaining on one of the player's boards). Finally output the string 'Player cit> won after turns. 1. (char) A 10x10 array representing player one's ship placement 2. (char) A 10x10 array representing player two's ship placement 3. (char) A comma separated list of moves Example 1. (char) A string describing the outcome of the game 000 ' Background: You have always dreamed of being a pirate one day. In order to be a good pirate, you train every day by playing your favorite game, Battleship. Now that you know iteration in MATLAB, you realize that you can become King of the Pirates with the power of MATLAB! Function Description: 00" Battleship is a two-player guessing game in which each player arranges a fleet of ships on a 10x10 grid. The players then take tums guessing where on the grid the opponent's ships are located. The game ends when one player has "sunk all of the other player's ships by guessing every grid coordinate containing part of a ship. On the left, a typical battleship board is shown below, where ships are colored in blue. On the right is our MATLAB representation of the same board. moves 'E3, H4, C2,E8,C3,Cs,C4,IS,I18,I4,C4, D18,110,H9 winner battleship(p1, p2, moves) ->'Player 1 won after 7 turns.' Notes There will aways be a winner, but there may be more moves listed than are necessary to end the game turn consists of both players making a guess, unless the game ends after player one's ABCDEFGHI A Players will never guess a square that is not on the grid. 0 0 0 Hints: The strtok function may be useful. 10 Given a list of moves and the game boards of both players, play out a game of battleship. The third input will be given in the form pl guess,, ...'. To play out a turn, mark player one's guess on player two's board. If player one Continued... Function Name: battleship didn't win the game, mark player two's guess on player one's board. Repeat this process until the game is over (when there are no O's remaining on one of the player's boards). Finally output the string 'Player cit> won after turns. 1. (char) A 10x10 array representing player one's ship placement 2. (char) A 10x10 array representing player two's ship placement 3. (char) A comma separated list of moves Example 1. (char) A string describing the outcome of the game 000 ' Background: You have always dreamed of being a pirate one day. In order to be a good pirate, you train every day by playing your favorite game, Battleship. Now that you know iteration in MATLAB, you realize that you can become King of the Pirates with the power of MATLAB! Function Description: 00" Battleship is a two-player guessing game in which each player arranges a fleet of ships on a 10x10 grid. The players then take tums guessing where on the grid the opponent's ships are located. The game ends when one player has "sunk all of the other player's ships by guessing every grid coordinate containing part of a ship. On the left, a typical battleship board is shown below, where ships are colored in blue. On the right is our MATLAB representation of the same board. moves 'E3, H4, C2,E8,C3,Cs,C4,IS,I18,I4,C4, D18,110,H9 winner battleship(p1, p2, moves) ->'Player 1 won after 7 turns.' Notes There will aways be a winner, but there may be more moves listed than are necessary to end the game turn consists of both players making a guess, unless the game ends after player one's ABCDEFGHI A Players will never guess a square that is not on the grid. 0 0 0 Hints: The strtok function may be useful. 10 Given a list of moves and the game boards of both players, play out a game of battleship. The third input will be given in the form pl guess,, ...'. To play out a turn, mark player one's guess on player two's board. If player one Continued

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions