-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.hpp
79 lines (69 loc) · 1.93 KB
/
move.hpp
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
#ifndef __move_hpp
#define __move_hpp
#include "enums.hpp"
#include "constants.hpp"
struct move_packed;
struct move
{
PieceType::EPieceType piece;
PieceType::EPieceType captured;
PieceType::EPieceType promoted;
Sq::ESq from, to;
MoveType::EMoveType type;
MoveType::ESpecialMoveType special;
};
struct history_elem
{
Sq::ESq epSq_before_move;
unsigned fifty_count_before_move;
bool castling_before_move[CastlingRights::Total];
};
bool operator==( const move& o, const move& a )
{
if((a.piece != o.piece) || (a.from != o.from) || (a.to != a.to)) return false;
else if(a.special == MoveType::promotion && a.promoted != o.promoted) return false;
else if(a.type == MoveType::capture && a.captured != o.captured) return false;
else return true;
}
/////////////////////////////////
struct move_packed
{
move_packed( const move& m )
{
piece = (unsigned)m.piece;
captured = (unsigned)m.captured;
promoted = (unsigned)m.promoted;
from = (unsigned)m.from;
to = (unsigned)m.to;
type = (unsigned)m.type;
special = (unsigned)m.special;
}
move_packed():
piece (0),
captured(0),
promoted(0),
from (0),
to (0),
type (0),
special (0){}
unsigned piece : 4;
unsigned captured : 4;
unsigned promoted : 4;
unsigned from : 6;
unsigned to : 6;
unsigned type : 2;
unsigned special : 3;
};
move MoveFromMovePacked( const move_packed& mp )
{
move m;
m.piece = (PieceType::EPieceType)(mp.piece);
m.captured = (PieceType::EPieceType)(mp.captured);
m.promoted = (PieceType::EPieceType)(mp.promoted);
m.from = (Sq::ESq)(mp.from);
m.to = (Sq::ESq)(mp.to);
m.type = (MoveType::EMoveType)(mp.type);
m.special = (MoveType::ESpecialMoveType)(mp.special);
return m;
}
#endif