Skip to content

Commit

Permalink
fixed immediate jump generation to just generate next board location
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluemer committed Apr 18, 2017
1 parent 7298345 commit 7f33fb6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/BitBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,53 +32,53 @@ int const BitBoard::getIndex(uint32_t piece)
return (int)std::log2(piece);
}

void BitBoard::addBlackJumps(std::vector<Move> &moves)
void BitBoard::addJumps(std::vector<Move> &moves)
{
uint32_t notOcc = ~(m_whitePieces|m_blackPieces);
for (int i = 0; i < 32; ++i) {
// grab the specific piece
uint32_t piece = m_blackPieces & 1<<i;
uint32_t piece = (m_isBlacksTurn) ? m_blackPieces & 1<<i : m_whitePieces & 1<<i;
if (piece) {
//
}
}
}

std::vector<Move> BitBoard::generateImmediateJumps(uint32_t piece)
std::vector<int> BitBoard::generateImmediateJumps(uint32_t piece)
{
std::vector<Move> moves;
std::vector<int> moves;
uint32_t notOcc = ~(m_whitePieces|m_blackPieces);
uint32_t temp;
bool isKing = piece & m_kings;
if (m_isBlacksTurn) {
temp = (rotl32(piece, 7) & upLeft) & m_whitePieces;
if ((rotl32(temp, 7) & upLeft) & notOcc)
addNewMove(piece, rotl32(piece, 14), moves);
moves.push_back(getIndex(rotl32(temp, 7)));
temp = (rotl32(piece, 1) & upRight) & m_whitePieces;
if ((rotl32(temp, 1) & upRight) & notOcc)
addNewMove(piece, rotl32(piece, 2), moves);
moves.push_back(getIndex(rotl32(temp, 1)));
if (isKing) {
temp = (rotr32(piece, 7) & downRight) & m_whitePieces;
if ((rotr32(temp, 7) & downRight) & notOcc)
addNewMove(piece, rotr32(piece, 14), moves);
moves.push_back(getIndex(rotr32(temp, 7)));
temp = (rotr32(piece, 1) & downLeft) & m_whitePieces;
if ((rotr32(temp, 1) & downLeft) & notOcc)
addNewMove(piece, rotr32(piece, 2), moves);
moves.push_back(getIndex(rotr32(temp, 1)));
}
} else {
temp = (rotr32(piece, 7) & downRight) & m_blackPieces;
if ((rotr32(temp, 7) & downRight) & notOcc)
addNewMove(piece, rotr32(piece, 14), moves);
moves.push_back(getIndex(rotr32(temp, 7)));
temp = (rotr32(piece, 1) & downLeft) & m_blackPieces;
if ((rotr32(temp, 1) & downLeft) & notOcc)
addNewMove(piece, rotr32(piece, 2), moves);
moves.push_back(getIndex(rotr32(temp, 1)));
if (isKing) {
temp = (rotl32(piece, 7) & upLeft) & m_blackPieces;
if ((rotl32(temp, 7) & upLeft) & notOcc)
addNewMove(piece, rotl32(piece, 14), moves);
moves.push_back(getIndex(rotl32(temp, 7)));
temp = (rotl32(piece, 1) & upRight) & m_blackPieces;
if ((rotl32(temp, 1) & upRight) & notOcc)
addNewMove(piece, rotl32(piece, 2), moves);
moves.push_back(getIndex(rotl32(temp, 1)));
}
}
return moves;
Expand Down

0 comments on commit 7f33fb6

Please sign in to comment.