2024-11-20 01:49:12 +00:00
|
|
|
//------------------------------------------------------------------------------------------------------------
|
|
|
|
// 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.
|
|
|
|
//--------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2024-11-19 23:54:26 +00:00
|
|
|
#include "gameplay.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2024-11-20 01:04:51 +00:00
|
|
|
|
|
|
|
#include "random_player.h"
|
|
|
|
#include "utils.h"
|
2024-11-19 23:54:26 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2024-11-20 00:11:06 +00:00
|
|
|
int main() {
|
2024-11-19 23:54:26 +00:00
|
|
|
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;
|
|
|
|
|
2024-11-20 03:34:14 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2024-11-19 23:54:26 +00:00
|
|
|
// Determine player types and initialize gameplay
|
2024-11-20 01:04:51 +00:00
|
|
|
Player *randomPlayerName, *strategicPlayerName;
|
2024-11-20 03:34:14 +00:00
|
|
|
if (equalsIgnoreCase(player1Type, "Random") && equalsIgnoreCase(player2Type, "Strategic")) {
|
2024-11-19 23:54:26 +00:00
|
|
|
randomPlayerName = new RandomPlayer(player1Name);
|
|
|
|
strategicPlayerName = new StrategicPlayer(player2Name);
|
2024-11-20 03:34:14 +00:00
|
|
|
} else if (equalsIgnoreCase(player1Type, "Strategic") && equalsIgnoreCase(player2Type, "Random")) {
|
2024-11-19 23:54:26 +00:00
|
|
|
randomPlayerName = new RandomPlayer(player2Name);
|
|
|
|
strategicPlayerName = new StrategicPlayer(player1Name);
|
2024-11-20 03:34:14 +00:00
|
|
|
} else if (equalsIgnoreCase(player1Type, "Random") && equalsIgnoreCase(player2Type, "Random")) {
|
2024-11-19 23:54:26 +00:00
|
|
|
randomPlayerName = new RandomPlayer(player2Name);
|
|
|
|
strategicPlayerName = new RandomPlayer(player1Name);
|
|
|
|
} else {
|
|
|
|
randomPlayerName = new StrategicPlayer(player2Name);
|
|
|
|
strategicPlayerName = new StrategicPlayer(player1Name);
|
|
|
|
}
|
|
|
|
|
2024-11-20 01:04:51 +00:00
|
|
|
Gameplay(rows, cols, randomPlayerName, strategicPlayerName)
|
|
|
|
.playGame();
|
2024-11-19 23:54:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|