-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.h
82 lines (64 loc) · 2.2 KB
/
types.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
//
// Created by Vincent on 23/09/2017.
//
#ifndef TOPPLE_TYPES_H
#define TOPPLE_TYPES_H
#include <cstdint>
#include <chrono>
#include <new>
#include <algorithm>
#include <iostream>
#define INF 32767
#define TO_MATE_SCORE(ply) (INF - (ply))
#define TO_MATE_PLY(score) (INF - (score))
#define MINCHECKMATE (TO_MATE_SCORE(MAX_TB_PLY))
#define MAX_TB_PLY 1024
#define MAX_PLY 255
const int TIMEOUT = -INF * 2;
constexpr unsigned int MB = 1048576;
// Bitboard
typedef uint64_t U64;
constexpr U64 ONES = ~U64(0);
// Timing
typedef std::chrono::steady_clock engine_clock;
#define CHRONO_DIFF(start, finish) std::chrono::duration_cast<std::chrono::milliseconds>((finish) - (start)).count()
// Evaluation parameter: {mgc, mgo, egc, ego}
typedef int32_t v4si_t __attribute__ ((vector_size (16))); // vector of 4 ints - gcc extension
inline std::ostream& operator<<(std::ostream& os, v4si_t v4si) {
os << "{" << v4si[0] << "," << v4si[1] << "," << v4si[2] << "," << v4si[3] << "}";
return os;
}
enum Piece {
PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
};
// Basic piece values for SEE and MVV/LVA ordering. Uses the standard assignment of point values * 100
constexpr int VAL[] = {100, 300, 300, 500, 900, INF};
// We frequently need to iterate over pieces, so here are the increment operators.
inline Piece& operator++(Piece &p) { return p = static_cast<Piece>(static_cast<int>(p) + 1); }
inline Piece operator++(Piece &p, int) { Piece tmp(p); ++p; return tmp; }
enum Team {
WHITE, BLACK
};
enum Square {
A1, B1, C1, D1, E1, F1, G1, H1,
A2, B2, C2, D2, E2, F2, G2, H2,
A3, B3, C3, D3, E3, F3, G3, H3,
A4, B4, C4, D4, E4, F4, G4, H4,
A5, B5, C5, D5, E5, F5, G5, H5,
A6, B6, C6, D6, E6, F6, G6, H6,
A7, B7, C7, D7, E7, F7, G7, H7,
A8, B8, C8, D8, E8, F8, G8, H8,
};
enum Direction {
D_SW = -9, D_S = -8, D_SE = -7, D_W = -1, D_X = 0, D_E = 1, D_NW = 7, D_N = 8, D_NE = 9
};
constexpr Direction rel_offset(Team side, Direction dir) {
return side ? Direction(-dir) : dir;
}
constexpr uint8_t rel_sq(Team side, uint8_t square) {
return side ? square ^ 56 : square;
}
constexpr uint8_t rel_rank(Team side, uint8_t rank) {
return side ? uint8_t(7 - rank) : rank;
}
#endif //TOPPLE_TYPES_H