//------------------------------------------------------------------------------------------------------------ // Team member 1: // Name: Sandipsinh Rathod // Email: sdr5549@psu.edu // Class: CMPSC 330 // // Team member 2: // Name: Sapan Shah // Email: scs6041@psu.edu // Class: CMPSC 330 // // Description: This program generates moves from two-player board game where // wither one player plays strategically and the other plays randomly. Or both players // play randomly or strategically. //-------------------------------------------------------------------------------------------------------------- #include "gameplay.h" #include #include #include "random_player.h" #include "utils.h" using namespace std; int main() { int rows, cols; char player1Name, player2Name; string player1Type, player2Type; // Read board dimensions cin >> rows >> cols; // Read player 1 details cin >> player1Name >> player1Type; // Read player 2 details cin >> player2Name >> player2Type; // Validate player types if (!equalsIgnoreCase(player1Type, "Random") && !equalsIgnoreCase(player1Type, "Strategic")) { cerr << "Error: Invalid player 1 type. Must be 'Random' or 'Strategic'." << endl; return 1; } if (!equalsIgnoreCase(player2Type, "Random") && !equalsIgnoreCase(player2Type, "Strategic")) { cerr << "Error: Invalid player 2 type. Must be 'Random' or 'Strategic'." << endl; return 1; } // Determine player types and initialize gameplay Player *player1, *player2; if (equalsIgnoreCase(player1Type, "Random") && equalsIgnoreCase(player2Type, "Strategic")) { player1 = new RandomPlayer(player1Name); player2 = new StrategicPlayer(player2Name); } else if (equalsIgnoreCase(player1Type, "Strategic") && equalsIgnoreCase(player2Type, "Random")) { player1 = new RandomPlayer(player2Name); player2 = new StrategicPlayer(player1Name); } else if (equalsIgnoreCase(player1Type, "Random") && equalsIgnoreCase(player2Type, "Random")) { player1 = new RandomPlayer(player2Name); player2 = new RandomPlayer(player1Name); } else { player1 = new StrategicPlayer(player2Name); player2 = new StrategicPlayer(player1Name); } if (player1->getName() != player1Name) { Player *tmp = player1; player1 = player2; player2 = tmp; } Gameplay(rows, cols, player1, player2) .playGame(); return 0; }