-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTournamentDriver.cpp
More file actions
63 lines (51 loc) · 1.8 KB
/
TournamentDriver.cpp
File metadata and controls
63 lines (51 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "CommandProcessing.h"
#include "GameEngine.h"
#include <iostream>
using namespace std;
/*
* testTournament()
* Demonstrates:
* 1. Processing of the tournament command
* 2. Validation through CommandProcessor::validate()
* 3. Execution through GameEngine::runTournament()
*
* Required by Assignment 3
*/
void testTournament()
{
cout << "=== Tournament Mode Driver ===\n\n";
// Example tournament command (can be edited for demo)
string inputCmd = "tournament -M map1.map,map2.map -P Aggressive,Cheater -G 3 -D 30";
cout << "Processing command: " << inputCmd << "\n\n";
CommandProcessor cp;
Command* cmd = new Command(inputCmd, " ");
// 1. Validate the command
bool valid = cp.validate(cmd);
cout << "Validation Result: " << (valid ? "VALID" : "INVALID") << "\n";
cout << "Command Effect: " << cmd->getEffect() << "\n\n";
if (!valid) {
cout << "Command rejected. Ending driver.\n";
delete cmd;
return;
}
// 2. Parse tournament parameters
vector<string> maps;
vector<string> strategies;
int games = 0;
int maxTurns = 0;
CommandProcessor::parseTournamentCommand(inputCmd, maps, strategies, games, maxTurns);
// 3. Show extracted parameters
cout << "Tournament Parameters:\n";
cout << "Maps: ";
for (auto& m : maps) cout << m << " ";
cout << "\nStrategies: ";
for (auto& s : strategies) cout << s << " ";
cout << "\nGames per map: " << games;
cout << "\nMax turns: " << maxTurns << "\n\n";
// 4. Run the tournament
GameEngine engine;
cout << "=== Running Tournament ===\n\n";
engine.runTournament(maps, strategies, games, maxTurns);
cout << "\n=== Tournament Driver Complete ===\n";
delete cmd;
}