-
Notifications
You must be signed in to change notification settings - Fork 0
/
aiplayer.h
43 lines (34 loc) · 1.57 KB
/
aiplayer.h
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
#ifndef AIPLAYER_H
#define AIPLAYER_H
#include <vector>
#include <random>
#include "hexboard.h"
#include "sampler.h"
#include "threadpool.h"
#include "move.h"
class AIPlayer
{
public:
AIPlayer(int sampleCount = 1000, int samplerCount = 8);
/* Simulate SampleCount many random games from hexBoard for each of the remaining moves. If firstMove is true, also try swapping the players
instead of playing a move. Return the move resulting in the most number of wins, or SWAP if swapping was more successful */
Move GetMove(const HexBoard& hexBoard, char myPlayer, bool firstMove);
// Test functions
friend void testAIPlayerGetAvailableMoves();
static const Move SWAP;
private:
// Clear Moves and place all availables moves on the specified board into Moves
void GetAvailableMoves(const HexBoard& hexBoard);
/* If move is TRY_SWAP, swap MoveBoard's players, otherwise play the move to be sampled on MoveBoard. Then simulate
SampleCount many random games from MoveBoard's state and return the number of wins. move is an index into Moves */
int SampleMove(int move);
static const int TRY_SWAP = Sampler::TRY_SWAP;
int SampleCount;
char MyPlayer;
std::vector<Move> Moves; // The remaining moves that can be played
HexBoard Board; // The main game board
HexBoard MoveBoard; // A board that a move to be tested will be played on
std::vector<Sampler> Samplers;
ThreadPool ThreadPool;
};
#endif