-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI.h
More file actions
70 lines (55 loc) · 1.67 KB
/
AI.h
File metadata and controls
70 lines (55 loc) · 1.67 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
66
67
68
69
70
#ifndef AI_H
#define AI_H
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <numeric>
#include <memory>
#include <stack>
#include "Board.h"
using namespace std;
// Conventions:
/*
Computer is always maximizing player.
*/
constexpr uint MAX_DEPTH = 64;
class AI
{
friend class Benchmark;
friend class UnitTest;
friend class DataBaseTest;
private:
int targetDepth; // Needed for iterative deepening
Board board;
ZobristHash transpositionHash;
PVTable pvTable;
// Gamehistory contains string board representation for
// exact comparison. (Hash can be overwritten)
//string boardToString() const;
//vector<pair<string, Move>> gameHistory;
// Chess playing functions
int NegaMax(int alpha, int beta, int depth, int ply, color side);
int QuiescenceSearch(int alpha, int beta, color side);
void extractPrincipalVariation(const U64& startKey, vector<Move>& pvLine, int maxPrintDepth, color side);
void inline sortMoves(MoveList& movelist, color side);
template<bool firstVisit> void getNextMove(MoveList&, MoveList::iterator&, color);
public:
AI(string FEN, color computerColor);
AI(string FEN, color computerColor, uint hashSize);
void setFen(string);
bool isUserMoveValid(const string&, color side);
pair<Move, Move> getBestMove(color forPlayer, int maxDepth, bool uciInfo);
void playStringMoves(const vector<string>& moves, color side);
void reset();
void resetHash();
void printDebug(string show = "prnbkqPRNBKQ");
void printBoard();
void printAscii();
void writeToHistory(const Move& move);
int nodesVisited;
int currentAge; // used to avoid clearing the hash table
color aiColor; // Piece color of computer
color sideToMove;
};
#endif