FreedomPay
Member
- Joined
- Aug 23, 2009
- Messages
- 161
- Reaction score
- 0
Thanks For the help Guys thanks very much
Last edited:
Basically i am stuck at :
int[][] boardGame = new int[10][10];
/**
* above is the 2D array constructor
*/
for (int row = 0; row < 10; row++)
{
for (int col = 0; col < 10; col++)
{
boardGame[row][col] = 0;
}
The following are the initial number of pieces for the entire game:
Piece Quantity
Settler 20
Castle 5
Tower 10
Mine 10
Then, the program should simulate the game play as follows:
• At each turn, the current state of the game board should be displayed
• 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 to follow for placing an item on the game board is as follows:
o If the dice value is between 1 and 3, inclusive, and there are “settler” pieces available, place a “settler” piece at [x][y] position on the game board
o If the dice value is 4 and there are “castle” pieces available, place a “castle” piece at [x][y] position on the game board
o If the dice value is 5 and there are “tower” pieces available, place a “tower” piece at [x][y] position on the game board
o If the dice value is 6 and there are “mine” pieces available, place a “mine” piece at [x][y] position on the game board
• If the [x][y] position on the game board is occupied, the computer player skips its turn.
Well, technically, you shouldnt declare the gameBoard as int. I believe you need 2 array; 1 char array and 1 int array.
Char array to store the piece while the int array store which player own the piece.