Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6c0054b
Rewrite how the board is stored and moves are made
razvanfilea Nov 20, 2019
1c41cd3
Remove 'ToList' MoveGen template arg, make some fixes
razvanfilea Nov 22, 2019
2bfdff3
Fix a critical error with Board::doMove()
razvanfilea Nov 24, 2019
9db8df9
Fix getPhase always returning ENDGAME
razvanfilea Nov 24, 2019
8fd4e8c
Improve the Evaluation function performance
razvanfilea Nov 24, 2019
bee2ee1
Fix Board::hasValidState and update Pawn PSQT
razvanfilea Nov 26, 2019
68d9853
Switch to the previous Multi Threading model
razvanfilea Nov 28, 2019
7154003
Remove KING_DANGER MoveGen
razvanfilea Nov 28, 2019
eb1963c
Add age attribute to the TranspositionTable
razvanfilea Nov 29, 2019
2da9711
Fix crash when generating legal moves
razvanfilea Nov 30, 2019
f922ceb
Rewrite how the UI processes positions
razvanfilea Nov 30, 2019
220b4d7
Rename NegaMax class to Search
razvanfilea Nov 30, 2019
ee721fd
Work on the ThreadPool
razvanfilea Nov 30, 2019
9a9e5ac
Solve a bug with Castling and disable EnPassant for now
razvanfilea Nov 30, 2019
faba2c2
Add Generated Nodes to Stats
razvanfilea Dec 1, 2019
d73bb5c
Remake the Settings Screen
razvanfilea Dec 1, 2019
9b46c3e
Clean ThreadSafeQueue and ThreadPool
razvanfilea Dec 1, 2019
d5d5ae0
Revert to the old Pawn PSQT
razvanfilea Dec 8, 2019
1b60b38
Re-enable EnPassant
razvanfilea Dec 9, 2019
c0be29b
Add Platform Specific Implementations for BSF and BSR
razvanfilea Dec 10, 2019
8a64bbc
Remove StackVector
razvanfilea Dec 10, 2019
7889cfa
Fix compile errors
razvanfilea Dec 10, 2019
e35ab03
Remake the Pawn Evaluation add Connected Bonus
razvanfilea Dec 11, 2019
459400d
Merge Rays.h into Bitboard.h
razvanfilea Dec 11, 2019
9be2e38
Fix Pawn Move Generation from last commit
razvanfilea Dec 12, 2019
9a37891
Remove Light Theme, add Rook on Queen File Evaluation
razvanfilea Dec 15, 2019
b81a38c
Rewrite Piece class to only use 1 byte
razvanfilea Dec 15, 2019
3a122a9
New icon
razvanfilea Dec 15, 2019
99a93b5
Release 1.0
razvanfilea Dec 15, 2019
b8651a6
Fix issues with the Pull Request
razvanfilea Dec 15, 2019
8c8a8d9
Delete MoveOrdering.h
razvanfilea Dec 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove KING_DANGER MoveGen
  • Loading branch information
razvanfilea committed Nov 28, 2019
commit 7154003a4803901502f2f23c9465c9d3711a3bf3
3 changes: 1 addition & 2 deletions ChessAndroid/app/src/main/cpp/chess/algorithm/MoveGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ enum GenType : unsigned char
{
ALL,
CAPTURES,
ATTACKS_DEFENSES,
KING_DANGER
ATTACKS_DEFENSES
};

template<GenType T>
Expand Down
57 changes: 12 additions & 45 deletions ChessAndroid/app/src/main/cpp/chess/algorithm/MoveGen.inl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ U64 MoveGen<T>::generateKnightMoves(const Piece &piece, const byte square, const

if constexpr (T == ALL)
attacks &= ~board.allPieces[piece.isWhite]; // Remove our pieces
else if (T == KING_DANGER) {
// Do nothing
} else if (T == CAPTURES)
else if (T == CAPTURES)
attacks &= board.allPieces[!piece.isWhite]; // Keep only their pieces
else if (T == ATTACKS_DEFENSES)
attacks &= board.occupied; // Keep only the pieces
Expand All @@ -67,60 +65,45 @@ U64 MoveGen<T>::generateKnightMoves(const Piece &piece, const byte square, const
template <GenType T>
U64 MoveGen<T>::generateBishopMoves(const Piece &piece, const byte square, const Board &board)
{
U64 occupancy = board.occupied;

if constexpr (T == KING_DANGER)
occupancy &= ~board.getType(toColor(piece.isWhite), PieceType::KING); // Remove the king

U64 attacks = PieceAttacks::getBishopAttacks(square, occupancy);
U64 attacks = PieceAttacks::getBishopAttacks(square, board.occupied);

if constexpr (T == ALL)
attacks &= ~board.allPieces[piece.isWhite]; // Remove our pieces
else if (T == CAPTURES)
attacks &= board.allPieces[!piece.isWhite]; // Keep only their pieces
else if (T == ATTACKS_DEFENSES)
attacks &= occupancy; // Keep only the pieces
attacks &= board.occupied; // Keep only the pieces

return attacks;
}

template <GenType T>
U64 MoveGen<T>::generateRookMoves(const Piece &piece, const byte square, const Board &board)
{
U64 occupancy = board.occupied;

if constexpr (T == KING_DANGER)
occupancy &= ~board.getType(toColor(piece.isWhite), PieceType::KING); // Remove their king

U64 attacks = PieceAttacks::getRookAttacks(square, occupancy);
U64 attacks = PieceAttacks::getRookAttacks(square, board.occupied);

if constexpr (T == ALL)
attacks &= ~board.allPieces[piece.isWhite]; // Remove our pieces
else if (T == CAPTURES)
attacks &= board.allPieces[!piece.isWhite]; // Keep only their pieces
else if (T == ATTACKS_DEFENSES)
attacks &= occupancy; // Keep only the pieces
attacks &= board.occupied; // Keep only the pieces

return attacks;
}

template <GenType T>
U64 MoveGen<T>::generateQueenMoves(const Piece &piece, const byte square, const Board &board)
{
U64 occupancy = board.occupied;

if constexpr (T == KING_DANGER)
occupancy &= ~board.getType(toColor(piece.isWhite), PieceType::KING); // Remove their king

U64 attacks = PieceAttacks::getBishopAttacks(square, occupancy)
| PieceAttacks::getRookAttacks(square, occupancy);
U64 attacks = PieceAttacks::getBishopAttacks(square, board.occupied)
| PieceAttacks::getRookAttacks(square, board.occupied);

if constexpr (T == ALL)
attacks &= ~board.allPieces[piece.isWhite]; // Remove our pieces
else if (T == CAPTURES)
attacks &= board.allPieces[!piece.isWhite]; // Keep only their pieces
else if (T == ATTACKS_DEFENSES)
attacks &= occupancy; // Keep only the pieces
attacks &= board.occupied; // Keep only the pieces

return attacks;
}
Expand All @@ -132,14 +115,12 @@ U64 MoveGen<T>::generateKingMoves(const Piece &piece, const byte square, const B

if constexpr (T == ALL)
attacks &= ~board.allPieces[piece.isWhite]; // Remove our pieces
else if (T == KING_DANGER) {
// Do Nothing
} else if (T == CAPTURES)
else if (T == CAPTURES)
attacks &= board.allPieces[!piece.isWhite]; // Keep only their pieces
else if (T == ATTACKS_DEFENSES)
attacks &= board.occupied; // Keep only the pieces

if constexpr (T == CAPTURES || T == ATTACKS_DEFENSES || T == KING_DANGER)
if constexpr (T == CAPTURES || T == ATTACKS_DEFENSES)
return attacks;

U64 opponentsMoves{};
Expand All @@ -157,13 +138,6 @@ U64 MoveGen<T>::generateKingMoves(const Piece &piece, const byte square, const B
attacks &= ~opponentsMoves;
}

/*U64 opponentsMoves{};
MoveGen<KING_DANGER>::forEachAttack(!piece.isWhite, board, [&] (const U64 enemyAttacks) -> bool {
opponentsMoves |= enemyAttacks;
attacks &= ~enemyAttacks; // Remove Attacked Positions
return static_cast<bool>(attacks);
});*/

if (!attacks)
return 0ull;

Expand All @@ -188,11 +162,7 @@ U64 MoveGen<T>::generateKingMoves(const Piece &piece, const byte square, const B
&& isEmptyAndCheckFree(5)
&& isEmptyAndCheckFree(6))
{
// This shouldn't be needed because the Castling rights would not exist
/*if (const auto &other = board.getPiece(7, y);
other.type == PieceType::ROOK
&& piece.isSameColor(other))*/
attacks |= Pos(6, y).toBitboard();
attacks |= Pos(6, y).toBitboard();
}

// Queen Side
Expand All @@ -201,10 +171,7 @@ U64 MoveGen<T>::generateKingMoves(const Piece &piece, const byte square, const B
&& isEmptyAndCheckFree(2)
&& !board.getPiece(1, y))
{
/*if (const auto &other = board.getPiece(0, y);
other.type == PieceType::ROOK
&& piece.isSameColor(other))*/
attacks |= Pos(2, y).toBitboard();
attacks |= Pos(2, y).toBitboard();
}

return attacks;
Expand Down
1 change: 0 additions & 1 deletion ChessAndroid/app/src/main/cpp/chess/algorithm/NegaMax.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Settings;
class NegaMax final
{
static bool s_QuiescenceSearchEnabled;
static std::size_t s_ThreadCount;
static TranspositionTable s_SearchCache;
static short s_BestMoveFound;

Expand Down