Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Game of Battleship: Your task is to develop a program that plays a game of Battleship. The game is intended to be played between

The Game of Battleship: Your task is to develop a program that plays a game of Battleship. The game is intended to be played between one player and the computer. Basic Rules for the Game: The game is played on four grids, two for each player (however, since one of the players is the computer, the computers two grids are hidden from view). The grids are 10x10 square. The individual squares in the grid are identified by letter and number. On the major grid the player arranges ships and records the shots by the opponent. On the minor grid the player records his/her own shots. Before play begins, each player secretly arranges their ships on their major grid. Each ship occupies a number of consecutive squares on the grid, arranged either horizontally, vertically or diagonally (we will ignore Pythagoras for this project). The number of squares for each ship is determined by the type of the ship. The ships cannot overlap (i.e. only one ship can occupy any given square on the grid). The types and numbers of ships allowed are the same for each player. Although the player may decide their own ship types and sizes, here are some example ship types and sizes

Requirements: In particular, your program should satisfy the following requirements:

1. To begin the game the computer will ask how many ships each side is given, or optionally, provide a file name to read in the information.

2. The ships are represented as variables of type ship and is stored as linked list. Using linked lists is a requirement for this assignment.

typedef struct ship {

char shiptype[20];

int shipsize;

int X Location;

int Y Location;

int X Hit;

int Y Hit;

struct ship pt;

} ship;

Ship Type, Board Symbol, Ship Size:

Aircraft Carrier A 5

Battleship B 4

Cruiser C 3

Submarine S 3

Patrol Boat P 2

Kayak K 1

Row boat R 1

You are allowed to add attributes to this definition, but not remove any.

3. For each ship added a new node is created in the linked list.

4. The player will be given the option to fill out the structure information at the beginning of the game, or read in the information from a file. The information to be entered is:

ship type

ship size

X-location

Y-location

Other attribute information of your choice.

5. The computer will place the same type, and number of ships, at locations of his own choosing.

Use a random X,Y location for the bow of the ship.

The remaining X,Y values must be in a horizontal, vertical, or diagonal sequence.

No X,Y values of the ship may be off grid. Your program must check for this and not allow players to break this rule.

I don't exactly know how to create this linked list. Thanks ahead of time.

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

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago