-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
78 lines (60 loc) · 1.73 KB
/
util.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
// provides various structs, classes, and helper functions
#ifndef UTIL_H
#define UTIL_H
#include <iostream>
#include <sstream>
#include <map>
#include <vector>
#include <string>
#include <memory>
#include <cstdlib> // ! added for abs()
using namespace std;
enum class PieceType
{
King,
Queen,
Bishop,
Rook,
Knight,
Pawn,
};
// 0 based coordinates ( eg. "a1" becomes (0, 0) )
//! (column, row) not the opposite
struct Position
{
int col, row;
Position() = default;
Position(const int col, const int row);
// ctor with a pos string (eg. "e4")
Position(const string &pos);
};
bool operator==(const Position &p1, const Position &p2);
bool operator!=(const Position &p1, const Position &p2);
string posToStr(const Position &p);
// MOVE
struct Move
{
Position startPos, endPos;
bool captured = false;
PieceType capturedPt;
bool enPassentCapture = false;
Position epCaptureLoc;
bool upgradePiece = false;
PieceType upgradeTo;
bool isCastleMove = false;
Move();
Move(const Position &startPos, const Position &endPos);
Move(const string &startPos, const string &endPos);
Move(const Position &startPos, const Position &endPos, bool isCastleMove);
Move(const Position &startPos, const Position &endPos, bool captured, PieceType pt);
Move(const Position &startPos, const Position &endPos, bool captured, PieceType pt, const Position &epc);
};
bool operator==(const Move &m1, const Move &m2);
bool operator!=(const Move &m1, const Move &m2);
// Constants for sentinel Position values
extern const Position ILLEGAL_MOVE;
extern const Position INVALID_INPUT;
// Constants to store the size of the grid
extern const int NUM_COLS;
extern const int NUM_ROWS;
#endif