-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.hpp
More file actions
99 lines (71 loc) · 2.24 KB
/
Utils.hpp
File metadata and controls
99 lines (71 loc) · 2.24 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
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
97
98
99
#ifndef UTILS_HPP
#define UTILS_HPP
#include <SDL2/SDL.h>
#include <iostream>
#include <bitset>
using namespace std;
struct Color{
int r, g, b, a;
};
struct Position{
int row, col;
bool operator==(const Position& rhs){
return this->row == rhs.row && this->col == rhs.col;
}
ostream& operator<<(ostream& os){
os << "row: " << row << " col: " << col << endl;
return os;
}
};
enum class PieceType {
WhitePawn=0, WhiteKnight, WhiteBishop, WhiteQueen, WhiteKing, WhiteRook, BlackPawn, BlackKnight, BlackBishop, BlackQueen, BlackKing, BlackRook, Nothing
};
namespace utils {
inline float hireTimeInSeconds() {
float t = SDL_GetTicks();
t *= 0.001f;
return t;
}
inline void printBitboard(bitset<64>& selected){
for (int i = 0; i < 64; ++i){
if (i % 8 == 0){
cout << '\n';
}
int n = 63 - i;
cout << selected[n] << ' ';
}
cout << endl;
}
//Do everthing with bit operations....
// uint8_t WhitePawn = 1; // 00000001;
// uint8_t WhiteKnight = 2; //00000010;
// uint8_t WhiteBishop = 4; //00000100;
// uint8_t WhiteQueen = 8; //00001000;
// uint8_t WhiteKing = 16; //00010000;
// uint8_t WhiteRook = 32; //00100000;
// uint8_t BlackPawn = 129; // 10000001;
// uint8_t BlackKnight = 130; // 10000010;
// uint8_t BlackBishop = 132; // 10000100;
// uint8_t BlackQueen = 136; // 10001000;
// uint8_t BlackKing = 144; // 10010000;
// uint8_t BlackRook = 160; //10100000;
// inline bool isWhitePiece(uint8_t piece){
// return (piece & (uint8_t)128) == 0; // if it is black it should be 128
// }
// inline bool isKnight(uint8_t piece){
// return (piece & (uint8_t)2) == 2;
// }
// inline bool isBishop(uint8_t piece){
// return (piece & (uint8_t)4) == 4;
// }
// inline bool isQueen(uint8_t piece){
// return (piece & (uint8_t)8) == 8;
// }
// inline bool isKing(uint8_t piece){
// return (piece & (uint8_t)16) == 16;
// }
// inline bool isRook(uint8_t piece){
// return (piece & (uint8_t)32) == 32;
// }
}
#endif