-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (50 loc) · 1.58 KB
/
Copy pathmain.cpp
File metadata and controls
65 lines (50 loc) · 1.58 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
64
65
/*
* grandeur is a board game similar to Splendor(TM).
* This implementation is a testbed for different AI players.
*
* This file includes all the code to set up a new game. The actual game loop
* and mechanics are in game_rules.cpp.
*
* (C) 2015 Eitan Frachtenberg. GPLv2 License.
*/
#include "constants.h"
#include "player.h"
#include "card.h"
#include "move.h"
#include "config.h"
#include "board.h"
#include <tbb/task_scheduler_init.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
namespace grandeur {
Config* g_config;
/////////////////////////////////////////////////////////////
void finalUpdate(MoveEvent event, const Board&, player_id_t pid,
const MoveNotifier::Payload&)
{
if (event == MoveEvent::GAME_WON) {
cout << "GAME OVER! Player " << pid << " wins!\n";
} else if (event == MoveEvent::TIE) {
cout << "GAME OVER! Stalemate!\n";
}
}
} // namespace
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
int main(int argc, char** argv)
{
using namespace grandeur;
g_config = new Config(vector<string>(argv + 1, argv + argc));
tbb::task_scheduler_init init(g_config->nthread_);
// Create shuffled card deck:
Cards deck(begin(g_deck), end(g_deck));
shuffle(begin(deck), end(deck), g_config->prng_);
auto board = g_config->createBoard(deck);
MoveNotifier::instance().registerObserver(finalUpdate);
mainGameLoop(board, deck, g_config->players_);
delete g_config;
return 0;
}