-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.hpp
67 lines (51 loc) · 1.29 KB
/
Game.hpp
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
//
// Created by Louis GARCZYNSKI on 3/30/16.
//
#pragma once
#include <ctime>
#include "PlayerColor.hpp"
#include "BoardPos.hpp"
#include "Constants.hpp"
#include "MoveScore.hpp"
#include "ChildBoard.hpp"
#include "ThreadData.hpp"
#include "Options.hpp"
#include <atomic>
#include <chrono>
#include <random>
template <typename Data, typename Value> class ThreadPool;
class Game
{
public:
Game(const Options& _options);
~Game();
bool play(BoardPos pos);
bool play();
PlayerColor getTurn() const;
bool isPlayerNext() const;
bool hasPosChanged(BoardPos pos) const;
bool isOverdue() const;
double getTimeDiff() const;
double getTimeTaken() const;
int getMovesExplored() const;
Score getCurrentScore() const;
Board *getState();
BoardPos getNextMove();
private:
typedef ThreadPool<ThreadData, MoveScore> Pool;
std::chrono::high_resolution_clock::time_point _start;
std::mt19937 _randomDevice;
Options _options;
double _timeLimit;
double _timeTaken;
std::atomic<int> _movesExplored;
int _constDepth;
int _depth;
Board* _state;
Board* _previousState;
PlayerColor _turn;
Score negamax(Board& node, int depth, Score alpha, Score beta, PlayerColor player);
MoveScore negamaxThread(ThreadData data);
BoardPos startNegamax(Board *node, PlayerColor player);
Pool *_pool;
};