I need help with my assignment on Programming. This is the task given.
Write a program to simulate a simplified board game called Fortify. The simplified game of Fortify is a two-player game played on a 10 x 10 game board, which is broken into 4 regions each of size 5 x 5. The objective of the game is to control as many as of the regions as possible to win through fortification. The winner is the player who has control over the most number of regions. This modified version of Fortify will be simulated using two computer players.
No user input is required for this game. The 10 x 10 board will be simulated using a 10 x 10 2D array. At the start, the game must randomly decide which computer player (1 or 2) will go first. This game will include the following pieces:
• “Infantry” piece – represents one infantry
• “Artillery” piece – represents one artillery
• “Cavalry” piece – represents one cavalry
The following are the initial number of pieces for the entire game:
Type of Piece Quantity
Then, the program should simulate the game play as follows:
• At each turn, the current state of the game board should be displayed, clearly identifying the 4 regions;
• At each turn, each computer player rolls a dice. Then, the program must also generate two random numbers that represent the x and y position in the 2D array.
• The rules for placing an item on the game board are as follows:
o If the dice value is between 1 and 2, inclusive, and there are infantry pieces available, place it at [x][y] position on the game board;
o If the dice value is 3 and 4, inclusive, and there are “artillery” pieces available, place an “artillery” piece at [x][y] position on the game board
o If the dice value is 5 or 6 and there are “cavalry” pieces available, place a “cavalry” piece at [x][y] position on the game board
• During each placing of an item any of the following may happen and the game board should be updated:
The current piece may be adjacent to at least one infantry piece The current piece is removed and returned to the stock
The current piece may be adjacent to at least two artillery pieces The current piece is removed and returned to the stock
• If the [x][y] position on the game board is occupied, the computer player skips its turn.
Overall, each position (or slot) in the displayed 10 x 10 2D game board can contain any of the following:
• E empty space
• I infantry
• A artillery
• C cavalry
Your program also needs to track which computer player owns which piece on the game board by region. Display the winner when the game ends.
The game ends when the following condition is satisfied:
• When there are no more remaining pieces to place on the game board OR
• After a cumulative of 80 turns.
At this point, your program should go through the game board and identify how many regions each player has fortified based on any of the following rules:
How to win a Region ( in order of priority)
The sum of the infantry and cavalry pieces occupies more than 50% of that region
One player has 25% more of the artillery pieces in comparison to the other player
One player has a row of 5 artillery in a region
• The program should print a “Tie” if both computer players end up with the same number of regions fortified.
Your program must, at least, include the following methods/functions with the correct input parameters and output type:
i. initializeGameBoard, which will take as input the player’s 2D array and assign empty slots containing E.
ii. placeItem, which will take as input the 2D array and place an item onto the game board depending on the above stated rules.
iii. computeWinner, which will take as input the 2D array and display the winner.
Your program also needs to track and print the following:
• The total number of pieces belonging to each computer player by region
• The total number of infantry pieces belonging to each computer player by region
• The total number of artillery pieces belonging to each computer player by region
• The total number of cavalry pieces belonging to each computer player by region