Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SPU CSC 2430 Winter 2021 Final Project Summary For your Project, you will develop a simple battleship game. Battleship is a guessing game for two

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

SPU CSC 2430 Winter 2021 Final Project Summary For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships. The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the positions of the opponent's ships. Players alternate turns by "firing" at the other player's ships. The objective of the game is to destroy the opposing player's entire fleet. In your game, "firing" will be allowing the player to take a guess at where on the grid their opponent may have placed a ship. Requirements You are to design the classes and implement the game. You are in full control of the choice of classes (please use classes appropriately or points will be deducted), data structures, algorithms, internal file format, detailed user interface scheme, or any other pertinent design decisions you need to make. The Battleship game you are implementing is a simplified version of the electronic Battleship game played in one player mode. The game is played on four grids, two for each player. Each player has a Battlefield Grid and a Firing Grid. The grids are a 10 by 10 square. The individual squares in the grid are identified by the x coordinate (indicated by a letter) followed by the y coordinate (indicated by a number). For example: A B C D E F H I J 1 2 3 4 5 6 7 8 9 10 SPU CSC 2430 Winter 2021 Final Project The Battlefield Grid holds the position of each player's fleet and the status of the fleet. The Firing Grid hold the coordinates of each "Firing" during the game and whether the shot was a hit or miss. Each player will have five ships to place on their Battlefield Grid. Each player will vary in size (the number of squares they take up) based on Ship Type. The ships cannot overlap, so only one Ship can occupy any given square in the grid. The types and numbers of ships allowed are the same for each player. Table 1 - Ship types and sizes Size 5 Type Carrier Battleship Cruiser Submarine Destroyer 4 3 3 2 The game is played in rounds. In each round, each player takes a turn to fire at a target square in the opponent's Battlefield Grid. The opponent then indicates whether the shot was a hit (a ship occupied the square) or a miss (there was no ship in the square). If the shot is a "miss", the attacked player marks their Battlefield Grid with a white peg (X in our game); if a "hit" they mark their Battlefield Grid with a red peg (O in our game). The attacking player then indicates the hit or miss on their Tracking Grid with the appropriate color peg (red (0) for "hit", white (X) for "miss") so that they can understand where the opponent's Ship might be. In the board game, once all the coordinates of a ship have been hit the ship is sunk, and the Ship's owner announces, "You sunk my battleship! (Or whatever the particular Ship is that was destroyed). For our purposes, we will consider a battleship sunk if the opponent has a single hit. When all of one player's ships are sunk, the other player wins the game. For your game, you will create a one-person version of the game where the computer' will play for the second player. Part 1 - Design the program. (30% of Total) Build a UML Class Diagram for any classes you create. Describe the principle functions you will be using their purpose, parameters, and return type. Create a Process Flow Diagram that describes how control flows through your program. Part 2 - Develop and test the code. (70% of Total) This seems self explanatory. SPU CSC 2430 Winter 2021 Final Project Game Setup At the beginning of the game, you will read a file that will be used to set up your Battlefield Grid. The file should be named "ship_placement.csv". This will be a comma-delimited file containing a line for each Ship in your fleet. Each line will be in the format: ShipType, StartPos, Direction StartType is a string identifying the type of Ship from Table 1. StartPos is the coordinates of the starting position of the Ship. For example, A5 or 09. Direction is a two-position indicator describing how the Ship should be positioned. The first position indicates whether the ship should be positioned horizontally or vertically (H or V). The second position indicates whether the ship should be laid out from left to right or right to left (L or R) in the case of a Horizontal positioning, or Down to Up or Up to Down (D or U) in the case of vertical positioning. For example, a line with the values "Battleship, D4, HR" would position a Battleship on the Battlefield Grid at squares D4, E4, F4, and G4. A line with the values "Cruiser, E9, VU" would position a Cruiser on the Battlefield Grid at squares E9, E8, and E7. De appropriate error checking on both the file input and the content. I will use various correct and incorrect files to test your code. Please keep in mind that ships can not overlap on the grid. After your Battlefield Grid is setup, randomly place the computer's ships on its Battlefield Grid. Again be careful not to overlap ships. Game Play Randomly select who will start the game, the Computer Player (CP), or the Human Player (HP). Proceed in rounds with both the CP and the HP getting a turn to "fire" into the other player's Battle Grid in turns. Firing is done by selecting a square on the opposing player's Battlefield Grid. The HP will choose the square by entering the grid coordinates. The CP will randomly choose a square that has not yet been selected If the selected square is occupied by a ship, that Ship is considered sunk. It's position should be notated on the Firing Grid and it should be identified as "sunk". If the selected square is not occupied, that square should be marked as "missed" on the Firing Grid so it will not be chosen again. When prompting the HP for firing coordinates, also give them the option to quit the game if desired. Winning the Game. When a player has sunk all of the opposing plays ships, the game ends. Identify the winner and display the Battlefield and Firing grids of each player. SPU CSC 2430 Winter 2021 Final Project Game Design suggestions: Create a Battlefield Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player. Create a Firing Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player. Create a Ship Class and instantiate a ship object for each ship type for both the HP and CP. Use a two-dimensional vector of char type to represent the grids. Make the game as fault-tolerant as possible. You never know what I will enter. After each round, display a summary showing the CP and HP status. Also, display the HP's Battlefield and Firing grids. Part 1 Rubric: Total points available for the Part 1: 69 Points are allocated as follows: UML Class Diagram Function List and Signatures Process Flow Diagram 30% 35% 35% Part 2 Rubric: Total points available for the Part 2: 161 Points are allocated as follows: Compilable Code Implements Solution Gameplay Uses Classes Uses Vectors Uses Exception Handling Commented Code 15% 20% 15% 15% 15% 15% 5% Deliverables: A single compressed (either.zip or .rar) file folder containing the source code files only. Don't just zip the whole project folder. Please label the folder in this format: [Last Name]+"_final.zip (or .rar)" For example: vickers_final.zip - Submit the file on Canvas AutoSave ship_placement Home Insert Draw Page Layout Formulas Data Review View Tell me Share Comments X Calibri (Body) v 12 A A = ab Wrap Text General Insert + Delete ! Format ZY D. 4 Ideas 8 Sort & Filter Find & Select Save As... Paste B IV = Merge & Center Conditional Format Cell Formatting as Table Styles Possible Data Loss Some features might be lost if you save this workbook in the comma-delimited (.csv) format. To preserve these features, save it in an Excel file format, A1 X Vfx Carrier B E F H K L M N 0 1 Carrier 183 VD z Battleship D1 HR 3 Cruiser 15 HI 4 Submarine D7 HR 5 Destroyer 19 VU P Q R 5 T U 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 28 32 ship_placement + Ready - 100% SPU CSC 2430 Winter 2021 Final Project Summary For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships. The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the positions of the opponent's ships. Players alternate turns by "firing" at the other player's ships. The objective of the game is to destroy the opposing player's entire fleet. In your game, "firing" will be allowing the player to take a guess at where on the grid their opponent may have placed a ship. Requirements You are to design the classes and implement the game. You are in full control of the choice of classes (please use classes appropriately or points will be deducted), data structures, algorithms, internal file format, detailed user interface scheme, or any other pertinent design decisions you need to make. The Battleship game you are implementing is a simplified version of the electronic Battleship game played in one player mode. The game is played on four grids, two for each player. Each player has a Battlefield Grid and a Firing Grid. The grids are a 10 by 10 square. The individual squares in the grid are identified by the x coordinate (indicated by a letter) followed by the y coordinate (indicated by a number). For example: A B C D E F H I J 1 2 3 4 5 6 7 8 9 10 SPU CSC 2430 Winter 2021 Final Project The Battlefield Grid holds the position of each player's fleet and the status of the fleet. The Firing Grid hold the coordinates of each "Firing" during the game and whether the shot was a hit or miss. Each player will have five ships to place on their Battlefield Grid. Each player will vary in size (the number of squares they take up) based on Ship Type. The ships cannot overlap, so only one Ship can occupy any given square in the grid. The types and numbers of ships allowed are the same for each player. Table 1 - Ship types and sizes Size 5 Type Carrier Battleship Cruiser Submarine Destroyer 4 3 3 2 The game is played in rounds. In each round, each player takes a turn to fire at a target square in the opponent's Battlefield Grid. The opponent then indicates whether the shot was a hit (a ship occupied the square) or a miss (there was no ship in the square). If the shot is a "miss", the attacked player marks their Battlefield Grid with a white peg (X in our game); if a "hit" they mark their Battlefield Grid with a red peg (O in our game). The attacking player then indicates the hit or miss on their Tracking Grid with the appropriate color peg (red (0) for "hit", white (X) for "miss") so that they can understand where the opponent's Ship might be. In the board game, once all the coordinates of a ship have been hit the ship is sunk, and the Ship's owner announces, "You sunk my battleship! (Or whatever the particular Ship is that was destroyed). For our purposes, we will consider a battleship sunk if the opponent has a single hit. When all of one player's ships are sunk, the other player wins the game. For your game, you will create a one-person version of the game where the computer' will play for the second player. Part 1 - Design the program. (30% of Total) Build a UML Class Diagram for any classes you create. Describe the principle functions you will be using their purpose, parameters, and return type. Create a Process Flow Diagram that describes how control flows through your program. Part 2 - Develop and test the code. (70% of Total) This seems self explanatory. SPU CSC 2430 Winter 2021 Final Project Game Setup At the beginning of the game, you will read a file that will be used to set up your Battlefield Grid. The file should be named "ship_placement.csv". This will be a comma-delimited file containing a line for each Ship in your fleet. Each line will be in the format: ShipType, StartPos, Direction StartType is a string identifying the type of Ship from Table 1. StartPos is the coordinates of the starting position of the Ship. For example, A5 or 09. Direction is a two-position indicator describing how the Ship should be positioned. The first position indicates whether the ship should be positioned horizontally or vertically (H or V). The second position indicates whether the ship should be laid out from left to right or right to left (L or R) in the case of a Horizontal positioning, or Down to Up or Up to Down (D or U) in the case of vertical positioning. For example, a line with the values "Battleship, D4, HR" would position a Battleship on the Battlefield Grid at squares D4, E4, F4, and G4. A line with the values "Cruiser, E9, VU" would position a Cruiser on the Battlefield Grid at squares E9, E8, and E7. De appropriate error checking on both the file input and the content. I will use various correct and incorrect files to test your code. Please keep in mind that ships can not overlap on the grid. After your Battlefield Grid is setup, randomly place the computer's ships on its Battlefield Grid. Again be careful not to overlap ships. Game Play Randomly select who will start the game, the Computer Player (CP), or the Human Player (HP). Proceed in rounds with both the CP and the HP getting a turn to "fire" into the other player's Battle Grid in turns. Firing is done by selecting a square on the opposing player's Battlefield Grid. The HP will choose the square by entering the grid coordinates. The CP will randomly choose a square that has not yet been selected If the selected square is occupied by a ship, that Ship is considered sunk. It's position should be notated on the Firing Grid and it should be identified as "sunk". If the selected square is not occupied, that square should be marked as "missed" on the Firing Grid so it will not be chosen again. When prompting the HP for firing coordinates, also give them the option to quit the game if desired. Winning the Game. When a player has sunk all of the opposing plays ships, the game ends. Identify the winner and display the Battlefield and Firing grids of each player. SPU CSC 2430 Winter 2021 Final Project Game Design suggestions: Create a Battlefield Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player. Create a Firing Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player. Create a Ship Class and instantiate a ship object for each ship type for both the HP and CP. Use a two-dimensional vector of char type to represent the grids. Make the game as fault-tolerant as possible. You never know what I will enter. After each round, display a summary showing the CP and HP status. Also, display the HP's Battlefield and Firing grids. Part 1 Rubric: Total points available for the Part 1: 69 Points are allocated as follows: UML Class Diagram Function List and Signatures Process Flow Diagram 30% 35% 35% Part 2 Rubric: Total points available for the Part 2: 161 Points are allocated as follows: Compilable Code Implements Solution Gameplay Uses Classes Uses Vectors Uses Exception Handling Commented Code 15% 20% 15% 15% 15% 15% 5% Deliverables: A single compressed (either.zip or .rar) file folder containing the source code files only. Don't just zip the whole project folder. Please label the folder in this format: [Last Name]+"_final.zip (or .rar)" For example: vickers_final.zip - Submit the file on Canvas AutoSave ship_placement Home Insert Draw Page Layout Formulas Data Review View Tell me Share Comments X Calibri (Body) v 12 A A = ab Wrap Text General Insert + Delete ! Format ZY D. 4 Ideas 8 Sort & Filter Find & Select Save As... Paste B IV = Merge & Center Conditional Format Cell Formatting as Table Styles Possible Data Loss Some features might be lost if you save this workbook in the comma-delimited (.csv) format. To preserve these features, save it in an Excel file format, A1 X Vfx Carrier B E F H K L M N 0 1 Carrier 183 VD z Battleship D1 HR 3 Cruiser 15 HI 4 Submarine D7 HR 5 Destroyer 19 VU P Q R 5 T U 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 28 32 ship_placement + Ready - 100%

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

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago