added 16bit move encoding
This commit is contained in:
1 parent
09dfeb7198
commit
b388adf692
1 file changed
+40
-3
+40
-3
@@ -1,15 +1,52 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
constexpr short moveFromMask = 0x3F;
|
||||||
|
constexpr short moveToMask = 0xFC0;
|
||||||
|
constexpr short moveFlagsMask = 0xF000;
|
||||||
|
|
||||||
enum MOVE_FLAGS {
|
enum MOVE_FLAGS {
|
||||||
|
quiet, doublePawnPush,
|
||||||
|
kingCastle, queenCastle,
|
||||||
|
capture, epCapture,
|
||||||
|
knightPromotion, bishopPromotion, rookPromotion, queenPromotion,
|
||||||
|
knightPromoCapture, bishopPromoCapture, rookPromoCapture, queenPromoCapture
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<const char*, 14> moveTypes {
|
constexpr std::array<const char*, 14> moveTypes {
|
||||||
|
"quiet", "doublePawnPush",
|
||||||
|
"kingCastle", "QueenCastle",
|
||||||
|
"capture", "epCapture",
|
||||||
|
"knightPromotion", "bishopPromotion", "rookPromotion", "queenPromotion",
|
||||||
|
"knightPromoCapture", "bishopPromoCapture", "rookPromoCapture", "queenPromoCapture"
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Move {
|
struct Move {
|
||||||
public:
|
public:
|
||||||
|
uint16_t m_move;
|
||||||
|
|
||||||
|
Move(){}
|
||||||
|
|
||||||
|
Move(int from, int to, int flags) {
|
||||||
|
m_move |= from;
|
||||||
|
m_move |= to << 6;
|
||||||
|
m_move |= flags << 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MoveFrom() {
|
||||||
|
return (m_move & moveFromMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MoveTo() {
|
||||||
|
return (m_move & moveToMask) >> 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetFlags() {
|
||||||
|
return (m_move & moveFlagsMask) >> 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintMove() {
|
||||||
|
std::cout << squareCoords[MoveFrom()] << squareCoords[MoveTo()];
|
||||||
|
std::cout << " (" << moveTypes[GetFlags()] << ")\n";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user