-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.h
96 lines (89 loc) · 1.92 KB
/
board.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef BOARD_H
#define BOARD_H
#include <cstdio>
#include <vector>
#include <string>
#include "boardConst.h"
class move;
class board
{
friend bool queryBook(board b, move &m);
private:
unsigned char squares[BOARD_SQRS];
unsigned char castleRights;
unsigned char plyClock;
unsigned char toMove;
unsigned char enPassantColumn;
void genSwipeMoves(std::vector<move> &result, int startpos, int dx, int dy) const;
void init(std::string);
bool checkFromDiag(int, int, int, unsigned char) const;
public:
bool operator==(const board b) const;
int eval() const;
board();
board(std::string);
unsigned long long hash() const;
bool semiEqual(const board b) const;
void dump(FILE *) const;
std::string dumpFEN() const;
std::vector<move> genMoves() const;
void executeMove(move m);
void flipToMove();
std::pair<bool,bool> inCheck() const;
move parseMove(std::string) const;
int moveGains(move m) const;
unsigned char getPlyClock() const
{
return plyClock;
}
unsigned char getToMove() const
{
return toMove;
}
};
class move
{
friend class board;
private:
unsigned char from, to;
unsigned char promotePiece;
public:
move(unsigned char from, unsigned char to)
{
this->from = from;
this->to = to;
this->promotePiece = 0;
}
move(unsigned char from, unsigned char to, unsigned char promotePiece)
{
this->from = from;
this->to = to;
this->promotePiece = promotePiece;
}
move()
{
from = to = promotePiece = 0;
}
std::string dump() const;
bool operator<(const move &m) const
{
if (from < m.from)
return true;
if (from > m.from)
return false;
if (to < m.to)
return true;
if (to > m.to)
return false;
return promotePiece < m.promotePiece;
}
bool operator!=(const move &m) const
{
return from != m.from || to != m.to || promotePiece != m.promotePiece;
}
bool operator==(const move &m) const
{
return from == m.from && to == m.to && promotePiece == m.promotePiece;
}
};
#endif //BOARD_H