-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove.cpp
More file actions
76 lines (72 loc) · 1.37 KB
/
Copy pathmove.cpp
File metadata and controls
76 lines (72 loc) · 1.37 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
#include "move.h"
#include "board.h"
#include <iostream>
using std::cout;
int Move::GetSource() const
{
return this->move & GET_SQUARE_MASK;
}
int Move::GetDest() const
{
return this->move >> 6 & GET_SQUARE_MASK;
}
int Move::GetMovedPiece() const
{
return this->move >> 12 & GET_PIECE;
}
int Move::GetPromotedPieceType() const
{
return this->move >> 16 & GET_PIECE;
}
bool Move::IsCapture() const
{
return this->move & CAPTURE_FLAG;
}
bool Move::IsEnpassant() const
{
return this->move & ENPASSANT_FLAG;
}
bool Move::IsDoublePush() const
{
return this->move & DOUBLE_PUSH_FLAG;
}
bool Move::IsCastling() const
{
return this->move & CASTLING_FLAG;
}
bool Move::IsQuietMove() const
{
return !(this->move & VIOLENT_MOVE_FLAG);
}
bool Move::IsMoveEmpty() const
{
return this->move == 0;
}
void Move::Clear()
{
this->move = 0;
}
void Move::PrintMove() const
{
cout << SQUARE_STR_TABLE[GetSource()] << SQUARE_STR_TABLE[GetDest()];
int promoted_piece = GetPromotedPieceType();
if (promoted_piece) cout << PieceToFen(promoted_piece);
}
Move::operator int() const
{
return this->move;
}
Move::operator int&()
{
return this->move;
}
Move::Move() : move(0)
{
}
Move::Move(int new_move) : move(new_move)
{
}
Move::Move(int source_square, int dest_square, int piece, int promoted_piece_type, int flag) :
move(source_square | dest_square << 6 | piece << 12 | promoted_piece_type << 16 | flag)
{
}