Write a C NIM Game Program with two Users using functions po
Write a C++ NIM Game Program with two Users, using functions, pointers, arrays. Write a program for playing a variation of the Subtraction game called the game of NIM. Our version of the game starts with up to 15 rods and up to 10 objects in each rod. Two players take turns removing objects from the rods. On a players turn, she chooses a rod and removes one or more objects from that rod. She can remove all objects from the rod. The player who takes the last object from the rods (so that all rods are empty) wins. You will implement the following algorithm in the main function. Each line in the algorithm will correspond to a function call. Important! Write your code incrementally. This means you should write each function one at a time, check that it compiles and runs properly, test it, and then implement the next function. i. Prompt and read the number of rods ii. Prompt and read the number of objects in each rod; iii. Draw the rods with percentages; iv. Display statistics; v. while (some rod is NOT empty) do vi. Prompt and read the next players move (Prompt and read the rod to modify and the number of objects to remove from the rod); vii. Remove the specified number of objects from the specified rod; viii. if (all rods are empty) then ix. Print a message congratulating the winning player. x. else xi. Redraw the rods with percentages; xii. Display statistics; xiii. Change to the other player; xiv. end xv. end All functions should be written AFTER the main procedure All function prototypes should be written for each function and placed BEFORE the main procedure. Each function should have a comment explaining what it does. Each function parameter should have a comment explaining the parameter. Your program MUST NOT use any global variables nor any global constants. In addition to implementing the above algorithm in the main function, you must define the following constants and variables in the main function: Define two constants to hold the maximum number rods (15) and the maximum number of objects per rod (10). The list of rods will be stored in an array of integers, where each integer represents the number of objects in that rod. Define a pointer variable for this array (see the lecture notes on Arrays and Pointers). Also define an integer to hold the size of this array. Define a variable that represents the current player (1 or 2). 7. Important: PLEASE READ! The following description provides specifications for the functions you will write that includes input parameters and return values. You are responsible for implementing these functions as described in these specifications in order to receive full credit. These functions may call additional helper functions that you define. You must determine good function names as well as good variable names for your function parameters and local variables. Important: PLEASE READ! The following description provides specifications for the functions you will write that includes input parameters and return values. You are responsible for implementing these functions as described in these specifications in order to receive full credit. These functions may call additional helper functions that you define. You must determine good function names as well as good variable names for your function parameters and local variables. 8. Write a function to implement step (i) of the algorithm. Define the function to have one input parameter that holds the maximum number of rods (see the constant defined above) and return an integer. Prompt the user for the number of rods used in the game. If the number entered is not between 1 and the maximum number of rods then display a warning message and prompt again. This is called input validation on the users input. 9. In the main function, allocate an array in the declared array pointer representing the list of rods (see description above) to have the same size as the number of rods returned from the function in step (i). 10. Write a procedure (this is a function that does not return a value and so is declared with a return type of void) that implements step (ii) of the algorithm. Define the procedure to have three input parameters: the array of rods, the size of the array, and the maximum number of objects per rod (see the constant defined above). This procedure will traverse the array of rods and call the following helper procedure for each rod in the list. Write a helper procedure that will prompt the user for the number of objects to place on this rod. If the number of objects entered for the rod is not between 1 and the maximum number of objects allowed then display a warning message and prompt again. Define this helper procedure to have three input parameters: the array entry for this rod (use pass by reference), the array index for this rod, and the maximum number of objects per rod. Important: Again, a procedure is a function that has no return value. You must define these functions as procedures by defining their return type as void. 11. Write a procedure to draw the rods to implement steps (iii) and (xi) of the algorithm. Draw each rod on its own row. In the row for rod i, there is a label Rod i: followed by n #s where n is the number of objects in rod i. The procedure should output an empty line before and after the first and last rows, respectively. For instance if rod 0 has 3 objects, rod 1 has zero objects, and rod 2 has 8 objects, the procedure (and helper procedures) should output: Rod 0: ### (27.273%) Rod 1: (0.000%) Rod 2: ######## (72.727%) Define the procedure to have two input parameters: the array of rods and the size of the array. First, calculate the total number of objects in the array of rods. Next, traverse the array of rods and call a helper procedure to display each complete row. Write the helper procedure to have three input parameters: the array index for this rod, the number of objects for this rod, and the total number of objects in the array of rods. The percentage displayed at the end of each row is the fraction of objects on this rod given the total number of objects in the array of rods (you just computed). Format each row using setw in iomanip and avoid using hard coded spaces. When there are ten or more rods to display, your output must align the labels Rod ?: and Rod ??: appropriately, where ? is a digit. Use setw to format the text between Rod and the :. Using setw, format the #s in a column of size ten that is left justified (look up the left specifier under iomanip). There needs to be five spaces between the column of #s and the percentage. Do NOT hard code these five spaces. Instead, use setw to format the last column for the percentage. Look up how to use the right specifier in iomanip to help you solve this problem. Also, format the percentage to show three digits after the decimal place. Decide if additional helper functions/procedures would be useful here. 12. Write a procedure to display the statistics for the list of rods that will be called in steps (iv) and (xii) of the algorithm. The statistics are 1) The rods with the smallest number of objects, 2) The rods with the largest number of objects, and 3) The average number of objects per rod taking into account only rods with objects. Define the procedure to have two input parameters: the array of rods and the size of the array. This procedure will call three helper procedures. Write a helper procedure to display the rods with the smallest number of objects. This procedure will have two input parameters: the array of rods and the size of the array. Note that there may be more than one rod with the smallest number of objects. Write a helper procedure to display the rods with the largest number of objects. This procedure will have two input parameters: the array of rods and the size of the array. Note that there may be more than one rod with the largest number of objects. Write a helper procedure to display the average number of objects per rod, but only taking into accout rods with at least one object. The average must be formatted to display two digits after the decimal place. 13. Write a function which returns true (boolean) if all the rods have zero objects and returns false otherwise. Call this function to implement steps (v) and (viii) of the algorithm. Note that the same function will be used for both steps. 14. Write a procedure to implement step (vi) of the algorithm where the current player makes her next move. Define the procedure to have five input parameters: the array of rods, the size of the array, player id, which rod chosen by the player on this turn, and how many objects the player would like to remove from this rod. The player id is either the integer 1 or 2 to indicate which player is taking a turn. This procedure will perform two steps with the help of helper functions/procedures as specified below: 1) Using the following helper functions and procedures, prompt and read for the rod from which to remove objects. If the player inputs an invalid rod id or chooses a rod with no objects then display a warning message and prompt again. These three helper functions/procedures will be called from this procedure. In addition, the last two helper procedures will call the first helper function. First, write a helper function to have one input parameter, the player id. Prompt the player to choose a rod (rod id) and then return this value. Thus, this helper function has a return type that is NOT void. Do not perform any input validation in this function. Next, write a second helper procedure to have three input parameters: the player id, the rod selected by this player, and the total number of rods (i.e., the size of the array of rods). This procedure will validate the rod selected by this player, i.e. the rod selected must be between 0 and n - 1 where n is the total number of rods. If the rod selected is invalid then the procedure displays a warning message and prompts for rod selection again by calling the first helper function. Finally, write a third helper procedure to have three input parameters: the array of rods, the player id, and the rod selected by this player. This procedure will validate whether the rod selected has at least one object. If the rod selected is invalid then the procedure displays a warning message and prompts for rod selection again by calling the first helper function. 2.) Using the following helper function, prompt and read how many objects to remove from the chosen rod. If the player inputs an invalid number of objects then display a warning message and prompt again. The number of objects to remove must be positive and must not exceed the number of objects on the chosen rod. The following helper function will be called from this procedure and will perform the following task described below. This procedure will check if the returned value from the helper function is valid and prompt the user again if necessary. Write a helper function to have two input parameters: the number of objects on the chosen rod and the rod id. The function will prompt the player for the number of objects to remove from the indicated rod and returns this value. Note this helper function will NOT perform any input validation checks. Instead the calling procedure will perform validation on the returned value from this helper function. 15. Write a procedure to implement step (vii) of the algorithm. Define the procedure to have three input parameters: the array of rods, the rod id of the chosen rod, and the number of objects to remove. This function will modify the array of rods by subtracting the specified number of objects from the chosen rod. 16. Write a procedure to implement step (ix) of the algorithm. Define the procedure to have a single input parameter that holds the player id. The procedure will print a message congratulating this winning player. The message should identify who won (player 1 or player 2). 17. Write a procedure to implement step (xiii) of the algorithm. Define this procedure to have a single input parameter that holds the player id. This procedure will switch the turn to the other player. In other words, if the player indicated in the input parameter is 1, then the procedure should change this value to 2. If the player indicated in the input parameter is 2, then the procedure should change this value to 1. 18. Be sure that there is a comment documenting each variable. View comments (1)
Solution
Solution: See the code below:
-----------------------------------------
//includes
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//reads number of rods to be used in game
int read_number_of_rods(int max_rods);
//reads objects per rod
void read_objects_per_rod(int *rods, int num_rods, int max_objects);
//reads objects for a given rod
void read_objects_for_a_rod(int *rods, int rod, int max_objects);
//draws rods
void draw_rods(int *rods, int num_rods);
//draw object in a rod
void draw_objects_in_rod(int rod, int num_objects, int total_objects);
//display statistics
void display_statistics(int *rods, int num_rods);
//display rods having smallest number of objects
void display_smallest_rods(int *rods, int num_rods);
//display rods having largest number of objects
void display_largest_rods(int *rods, int num_rods);
//display rods having average number of objects
void display_average_object_per_rod(int *rods, int num_rods);
//check if all rods are empty
bool are_all_rods_empty(int *rods, int num_rods);
//helper function to read a rod to modify
int choose_a_rod_to_modify(int player);
//helper function to check if rod selected to modify is valid
void validate_rod_to_modify(int player, int rod, int num_rods);
//helper function to validate object in rod selected to modify
void validate_objects_in_rod(int *rods, int player, int rod);
//defines rod from which to remove objects
int define_rod(int *rods, int num_rods, int player);
//functon to choose number of objects to be removed from a rod
int choose_object_to_remove_from_rod(int rod);
//function to validate objects to be removed from rod being modified
void validate_objects_to_remove_from_rod(int rod, int num_objects,
int objects_to_remove);
//function to define object to remove from rod
int define_objects_to_remove(int *rods, int rod);
//function to perform a move by player
void perform_move(int *rods, int num_rods, int player, int &rod,
int &objects_to_remove);
//function to remove objects from rod
void remove_objects_from_rod(int *rods, int rod, int objects_to_remove);
//function to display winning player
void display_winning_player(int player);
//function to change player
void change_player(int &player);
/**
* main() function
*/
int main() {
const int MAX_RODS = 15;
const int MAX_OBJECTS = 10;
int num_rods; //number of rods
int *rods; //objects in rods
int num_players = 2; //maximum number of players
//read number of rods
num_rods = read_number_of_rods(MAX_RODS);
//array for objects in rods
rods = new int[num_rods];
//read objects per rod
read_objects_per_rod(rods, num_rods, MAX_OBJECTS);
//draw rods
draw_rods(rods, num_rods);
//display statistics
display_statistics(rods, num_rods);
//while loop
int current_player = 1; //player indicator
int rod_to_modify; //rod being modified
int objects_to_remove; //objects to be removed from rod being modified
while (!are_all_rods_empty(rods, num_rods)) {
if (current_player <= num_players) {
//perform move
perform_move(rods, num_rods, current_player, rod_to_modify,
objects_to_remove);
//remove objects from rod
remove_objects_from_rod(rods, rod_to_modify, objects_to_remove);
//check all rods empty
bool all_rods_empty = are_all_rods_empty(rods, num_rods); //flag to mark rods empty
//all rods empty
if (all_rods_empty) {
//display winning player
display_winning_player(current_player);
} else {
//draw rods
draw_rods(rods, num_rods);
//display statistics
display_statistics(rods, num_rods);
//change player
change_player(current_player);
}
}
}
return 0;
}
//function definition for reading rods
int read_number_of_rods(int max_rods) {
int num_rods; //number of rods
//read number of rods
cout << \"Enter number of rods:\";
cin >> num_rods;
//check if valid
while (1) {
if (num_rods < 1 || num_rods > max_rods) {
cout << \"Not a valid value for number of rods. Enter again:\";
cin >> num_rods;
} else
break;
}
return num_rods;
}
//function definition for reading objects per rod
void read_objects_per_rod(int *rods, int num_rods, int max_objects) {
//read number of objects in each rod
for (int i = 0; i < num_rods; i++) {
read_objects_for_a_rod(rods, i, max_objects);
}
}
//helper function for read_objects_per_rod
void read_objects_for_a_rod(int *rods, int rod, int max_objects) {
cout << \"Enter number of objects in rod \" << rod << \":\";
cin >> rods[rod];
//check if valid
int objects = rods[rod];
while (1) {
if (objects < 1 || objects > max_objects) {
cout << \"Not a valid value for number of objects. Enter again:\";
cin >> rods[rod];
} else
break;
}
}
//function definition to draw rods
void draw_rods(int *rods, int num_rods) {
int total_objects = 0;
for (int i = 0; i < num_rods; i++) {
total_objects += rods[i];
}
cout << endl;
for (int i = 0; i < num_rods; i++) {
int num_objects = rods[i];
draw_objects_in_rod(i, num_objects, total_objects);
//cout<<setw(5);
double percentage = ((double) num_objects / (double) total_objects)
* 100.00;
cout << setprecision(5) << \"(\" << percentage << \"%)\" << endl;
}
cout << endl;
}
//helper function for draw_rods()
void draw_objects_in_rod(int rod, int num_objects, int total_objects) {
cout << setw(5) << left << \"Rod\" << rod << \":\";
for (int j = 0; j < num_objects; j++) {
cout << \"#\";
}
}
//display statistics
void display_statistics(int *rods, int num_rods) {
display_smallest_rods(rods, num_rods);
display_largest_rods(rods, num_rods);
display_average_object_per_rod(rods, num_rods);
}
//display rods having smallest number of objects
void display_smallest_rods(int *rods, int num_rods) {
int smallest_rods[num_rods];
int j = 0;
int smallest = 0;
smallest_rods[j] = smallest;
for (int i = 1; i < num_rods; i++) {
if (rods[i] < rods[smallest]) {
smallest = i;
smallest_rods[j] = smallest;
} else if (rods[i] == rods[smallest]) {
j++;
smallest_rods[j] = i;
}
}
cout << \"Rods with smallest number of objects is/are:\";
for (int k = 0; k <= j; k++)
cout << smallest_rods[k] << \" \";
cout << endl;
}
//display rods having largest number of objects
void display_largest_rods(int *rods, int num_rods) {
int largest_rods[num_rods];
int j = 0;
int largest = 0;
largest_rods[j] = largest;
for (int i = 1; i < num_rods; i++) {
if (rods[i] > rods[largest]) {
largest = i;
largest_rods[j] = largest;
} else if (rods[i] == rods[largest]) {
j++;
largest_rods[j] = i;
}
}
cout << \"Rods with largest number of objects is/are:\";
for (int k = 0; k <= j; k++)
cout << largest_rods[k] << \" \";
cout << endl;
}
//display rods having average number of objects
void display_average_object_per_rod(int *rods, int num_rods) {
double total_objects = 0.0, average_objects;
int rods_with_zero_objects = 0;
for (int i = 0; i < num_rods; i++) {
int num_objects = rods[i];
total_objects += num_objects;
if (num_objects == 0)
rods_with_zero_objects++;
}
//calcu;late average
average_objects = total_objects / (num_rods - rods_with_zero_objects);
cout << \"Average number of objects per rod is:\" << average_objects << endl;
}
//function definition to check if all rods are empty
bool are_all_rods_empty(int *rods, int num_rods) {
bool all_rods_empty = true; //flag to mark rods empty
for (int i = 0; i < num_rods; i++) {
if (rods[i] > 0) {
all_rods_empty = false;
break;
}
}
return all_rods_empty;
}
//helper function to read a rod to modify
int choose_a_rod_to_modify(int player) {
int rod_to_modify;
cout << \"For player \" << player << \":\" << endl;
cout << \"Which rod to modify?\";
cin >> rod_to_modify;
return rod_to_modify;
}
//helper function to check if rod selected to modify is valid
void validate_rod_to_modify(int player, int rod, int num_rods) {
//check if valid
//cout<<\"For player \"<<player<<\":\"<<endl;
while (1) {
if (rod < 0 || rod > num_rods - 1) {
cout << \"Not a valid value for rods. Enter again:\";
choose_a_rod_to_modify(player);
} else
break;
}
}
//helper function to validate object in rod selected to modify
void validate_objects_in_rod(int *rods, int player, int rod) {
//check if number of objects valid
while (1) {
if (rods[rod] < 1) {
cout
<< \"Not a valid number of objects in rod selected. Enter again:\";
choose_a_rod_to_modify(player);
} else
break;
}
}
//defines rod from which to remove objects
int define_rod(int *rods, int num_rods, int player) {
int rod = choose_a_rod_to_modify(player);
validate_rod_to_modify(player, rod, num_rods);
validate_objects_in_rod(rods, player, rod);
return rod;
}
//functon to choose number of objects to be removed from a rod
int choose_object_to_remove_from_rod(int rod) {
int objects_to_remove;
cout << \"Objects to remove from rod \" << rod << \":\";
cin >> objects_to_remove;
return objects_to_remove;
}
//function to validate objects to be removed from rod being modified
void validate_objects_to_remove_from_rod(int rod, int num_objects,
int objects_to_remove) {
//check if number of objects valid
while (1) {
if (objects_to_remove < 0 || objects_to_remove > num_objects) {
cout << \"Not a valid number of objects to be removed from rod \"
<< rod << \" Enter again:\" << endl;
objects_to_remove = choose_object_to_remove_from_rod(rod);
} else
break;
}
}
//function to define object to remove from rod
int define_objects_to_remove(int *rods, int rod) {
int objects_to_remove = choose_object_to_remove_from_rod(rod);
validate_objects_to_remove_from_rod(rod, rods[rod], objects_to_remove);
return objects_to_remove;
}
//function to perform a move by player
void perform_move(int *rods, int num_rods, int player, int &rod,
int &objects_to_remove) {
rod = define_rod(rods, num_rods, player);
objects_to_remove = define_objects_to_remove(rods, rod);
}
//function to remove objects from rod
void remove_objects_from_rod(int *rods, int rod, int objects_to_remove) {
//remove objects from rod
rods[rod] -= objects_to_remove;
}
//function to display winning player
void display_winning_player(int player) {
cout << \"Congratulations of winning the game, Player \" << player << \"!\"
<< endl;
}
//function to change player
void change_player(int &player) {
//change player
if (player == 1)
player = 2;
else
player = 1;
}
/**
* This program simulates NIM game.
*/
//includes
#include <iostream>
#include <cmath>
using namespace std;
//reads number of rods to be used in game
int read_number_of_rods(int max_rods);
//reads objects per rod
void read_objects_per_rod(int *rods, int num_rods, int max_objects);
//reads objects for a given rod
void read_objects_for_a_rod(int *rods, int rod, int max_objects);
//draws rods
void draw_rods(int *rods, int num_rods);
//draw object in a rod
void draw_objects_in_rod(int rod, int num_objects, int total_objects);
/**
* main() function
*/
int main() {
const int MAX_RODS=15;
const int MAX_OBJECTS=10;
int num_rods; //number of rods
int *rods; //objects in rods
int num_players=2; //maximum number of players
//read number of rods
num_rods=read_number_of_rods(MAX_RODS);
//array for objects in rods
rods=new int[num_rods];
//read objects per rod
read_objects_per_rod(rods,num_rods,MAX_OBJECTS);
//draw rods
draw_rods(rods,num_rods);
//display statistics
cout<<\"Number of rods:\"<<num_rods<<endl;
for(int i=0;i<num_rods;i++)
{
cout<<\"Number of objects in rod \"<<i+1<<\":\"<<rods[i]<<endl;
}
//while loop
int rod=0; //counter for rod
int current_player=1; //player indicator
int rod_to_modify; //rod being modified
int objects_to_remove; //objects to be removed from rod being modified
while(rod < num_rods && rods[rod]>0)
{
if(current_player<=num_players)
{
cout<<\"For player \"<<current_player<<\":\"<<endl;
cout<<\"Which rod to modify?\";
cin>>rod_to_modify;
cout<<\"Objects to remove from rod?\";
cin>>objects_to_remove;
//remove objects from rod
rods[rod_to_modify-1]-=objects_to_remove;
//check all rods empty
bool all_rods_empty=false; //flag to mark rods empty
for(int i=0;i<num_rods;i++)
{
if(rods[i]<=0)
{
all_rods_empty=true;
}
else
{
all_rods_empty=false;
}
}
//all rods empty
if(all_rods_empty)
{
cout<<\"Congratulations of winning the game, Player \"<<current_player<<\"!\"<<endl;
}
else
{
//draw rods
for(int i=0;i<num_rods;i++)
{
//cout<<\"Rod \"<<i+1<<\":\"<<endl;
for(int j=0;j<rods[i];j++)
{
cout<<\"%\";
}
cout<<endl;
}
//display statistics
cout<<\"Number of rods:\"<<num_rods<<endl;
for(int i=0;i<num_rods;i++)
{
cout<<\"Number of objects in rod \"<<i+1<<\":\"<<rods[i]<<endl;
}
//change player
if(current_player==1)
current_player=2;
else
current_player=1;
}
}
rod++;
}
return 0;
}
//function definition for reading rods
int read_number_of_rods(int max_rods)
{
int num_rods; //number of rods
//read number of rods
cout<<\"Enter number of rods:\";
cin>>num_rods;
//check if valid
while(1)
{
if(num_rods < 1 || num_rods > max_rods)
{
cout<<\"Not a valid value for number of rods. Enter again:\";
cin>>num_rods;
}
else
break;
}
return num_rods;
}
//function definition for reading obejcts per rod
void read_objects_per_rod(int *rods, int num_rods, int max_objects)
{
//read number of objects in each rod
for(int i=0;i<num_rods;i++)
{
read_objects_for_a_rod(rods,i,max_objects);
}
}
//helper function for read_objects_per_rod
void read_objects_for_a_rod(int *rods, int rod, int max_objects)
{
cout<<\"Enter number of objects in rod \"<<rod+1<<\":\";
cin>>rods[rod];
//check if valid
int objects=rods[rod];
while(1)
{
if(objects < 1 || objects > max_objects)
{
cout<<\"Not a valid value for number of objects. Enter again:\";
cin>>rods[rod];
}
else
break;
}
}
//function definition to draw rods
void draw_rods(int *rods, int num_rods)
{
cout<<endl;
int total_objects=0;
for(int i=0;i<num_rods;i++)
{
total_objects+=rods[i];
}
for(int i=0;i<num_rods;i++)
{
int num_objects=rods[i];
cout<<endl;
draw_objects_in_rod(i,num_objects,total_objects);
cout<<\"(\"<<(num_objects/total_objects)*100<<\"%)\"<<endl;
}
}
//helper function for draw_rods()
void draw_objects_in_rod(int rod, int num_objects, int total_objects)
{
cout<<\"Rod \"<<rod<<\":\";
for(int j=0;j<num_objects;j++)
{
cout<<\"#\";
}
}
------------------------------
Output:
--------------------------------
Enter number of rods:4
Enter number of objects in rod 0:3
Enter number of objects in rod 1:6
Enter number of objects in rod 2:5
Enter number of objects in rod 3:8
Rod 0:###(13.636%)
Rod 1:######(27.273%)
Rod 2:#####(22.727%)
Rod 3:########(36.364%)
Rods with smallest number of objects is/are:0
Rods with largest number of objects is/are:3
Average number of objects per rod is:5.5
For player 1:
Which rod to modify?3
Objects to remove from rod 3:4
Rod 0:###(16.667%)
Rod 1:######(33.333%)
Rod 2:#####(27.778%)
Rod 3:####(22.222%)
Rods with smallest number of objects is/are:0
Rods with largest number of objects is/are:1
Average number of objects per rod is:4.5
For player 2:
Which rod to modify?1
Objects to remove from rod 1:5
Rod 0:###(23.077%)
Rod 1:#(7.6923%)
Rod 2:#####(38.462%)
Rod 3:####(30.769%)
Rods with smallest number of objects is/are:1
Rods with largest number of objects is/are:2
Average number of objects per rod is:3.25
For player 1:
Which rod to modify?2
Objects to remove from rod 2:5
Rod 0:###(37.5%)
Rod 1:#(12.5%)
Rod 2:(0%)
Rod 3:####(50%)
Rods with smallest number of objects is/are:2
Rods with largest number of objects is/are:3
Average number of objects per rod is:2.6667
For player 2:
Which rod to modify?3
Objects to remove from rod 3:4
Rod 0:###(75%)
Rod 1:#(25%)
Rod 2:(0%)
Rod 3:(0%)
Rods with smallest number of objects is/are:2 3
Rods with largest number of objects is/are:0
Average number of objects per rod is:2
For player 1:
Which rod to modify?0
Objects to remove from rod 0:3
Rod 0:(0%)
Rod 1:#(100%)
Rod 2:(0%)
Rod 3:(0%)
Rods with smallest number of objects is/are:0 2 3
Rods with largest number of objects is/are:1
Average number of objects per rod is:1
For player 2:
Which rod to modify?1
Objects to remove from rod 1:1
Congratulations of winning the game, Player 2!
-------------------------------------











