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
Add Generated Nodes to Stats
  • Loading branch information
razvanfilea committed Dec 1, 2019
commit faba2c2c334933ae18176ea8a3fc5e23d6a898f2
9 changes: 6 additions & 3 deletions ChessAndroid/app/src/main/cpp/chess/BoardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,19 @@ StackVector<Pos, 27> BoardManager::getPossibleMoves(const Pos &selectedPos)
const Piece &piece = s_Board.getPiece(startSq);
U64 possibleMoves = piece.getPossibleMoves(startSq, s_Board);

// Make sure we are not capturing the king
possibleMoves &= ~s_Board.getType(s_Board.colorToMove, KING);

while (possibleMoves)
{
const byte destSq = Bitboard::findNextSquare(possibleMoves);
const Piece &destPiece = s_Board.getPiece(destSq);
if (destPiece.type == PieceType::KING)
continue;

Board board = s_Board;
board.doMove(startSq, destSq);

if (!board.hasValidState())
continue;

moves.emplace_back(Pos(destSq));
}

Expand Down
46 changes: 33 additions & 13 deletions ChessAndroid/app/src/main/cpp/chess/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,65 @@

#include <sstream>

std::chrono::time_point<std::chrono::steady_clock> Stats::_startTime;
std::atomic_size_t Stats::boardsEvaluated;
std::atomic_size_t Stats::nodesSearched;
std::chrono::time_point<std::chrono::steady_clock> Stats::s_StartTime;
std::atomic_size_t Stats::s_BoardsEvaluated;
std::atomic_size_t Stats::s_NodesSearched;
std::atomic_size_t Stats::s_NodesGenerated;

void Stats::setEnabled(const bool enabled) noexcept
{
_statsEnabled = enabled;
s_StatsEnabled = enabled;
}

void Stats::resetStats() noexcept
{
boardsEvaluated = 0;
nodesSearched = 0;
s_BoardsEvaluated = 0;
s_NodesSearched = 0;
s_NodesGenerated = 0;
}

void Stats::incrementBoardsEvaluated() noexcept
{
if (s_StatsEnabled)
++s_BoardsEvaluated;
}

void Stats::incrementNodesSearched() noexcept
{
if (s_StatsEnabled)
++s_NodesSearched;
}

void Stats::incrementNodesGenerated(const std::size_t amount) noexcept
{
if (s_StatsEnabled)
s_NodesGenerated += amount;
}

void Stats::startTimer() noexcept
{
_startTime = std::chrono::high_resolution_clock::now();
_elapsedTime = 0;
s_StartTime = std::chrono::high_resolution_clock::now();
s_ElapsedTime = 0;
}

void Stats::stopTimer() noexcept
{
const auto currentTime = std::chrono::high_resolution_clock::now();
_elapsedTime = std::chrono::duration<double, std::milli>(currentTime - _startTime).count();
s_ElapsedTime = std::chrono::duration<double, std::milli>(currentTime - s_StartTime).count();
}

double Stats::getElapsedTime() noexcept
{
return _elapsedTime;
return s_ElapsedTime;
}

std::string Stats::formatStats(const char separator) noexcept(false)
{
std::stringstream stream;

stream << "Boards Evaluated: " << static_cast<size_t>(boardsEvaluated) << separator
<< "Nodes Searched: " << static_cast<size_t>(nodesSearched) << separator
<< "Time Needed: " << _elapsedTime << " millis" << separator;
stream << "Boards Evaluated: " << static_cast<size_t>(s_BoardsEvaluated) << separator
<< "Nodes Searched: " << static_cast<size_t>(s_NodesSearched) << separator
<< "Nodes Generated: " << static_cast<size_t>(s_NodesGenerated) << separator;

return stream.str();
}
24 changes: 16 additions & 8 deletions ChessAndroid/app/src/main/cpp/chess/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@

class Stats final
{
inline static bool _statsEnabled = false;
inline static double _elapsedTime = 0;
static std::chrono::time_point<std::chrono::steady_clock> _startTime;
inline static bool s_StatsEnabled = false;
inline static double s_ElapsedTime = 0;
static std::chrono::time_point<std::chrono::steady_clock> s_StartTime;

static std::atomic_size_t s_BoardsEvaluated;
static std::atomic_size_t s_NodesSearched;
static std::atomic_size_t s_NodesGenerated;

public:
Stats() = delete;
Stats(const Stats&) = delete;
Stats(Stats&&) = delete;

static std::atomic_size_t boardsEvaluated;
static std::atomic_size_t nodesSearched;
static std::atomic_size_t allocationsCount;

static bool enabled() noexcept { return _statsEnabled; }
static bool isEnabled() noexcept { return s_StatsEnabled; }
static void setEnabled(bool enabled) noexcept;
static void resetStats() noexcept;

static void incrementBoardsEvaluated() noexcept;
static void incrementNodesSearched() noexcept;
static void incrementNodesGenerated(std::size_t amount) noexcept;

static void startTimer() noexcept;
static void stopTimer() noexcept;
static double getElapsedTime() noexcept;

static std::string formatStats(char separator) noexcept(false);
};
3 changes: 1 addition & 2 deletions ChessAndroid/app/src/main/cpp/chess/algorithm/Evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ short Evaluation::evaluate(const Board &board) noexcept
if (board.state == State::WINNER_BLACK)
return VALUE_WINNER_BLACK;

if (Stats::enabled())
++Stats::boardsEvaluated;
Stats::incrementBoardsEvaluated();

Score totalScore;

Expand Down
10 changes: 5 additions & 5 deletions ChessAndroid/app/src/main/cpp/chess/algorithm/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ short Search::negaMax(const Board &board, const short ply, short alpha, short be
return cache.value;
}

if (Stats::enabled())
++Stats::nodesSearched;

const auto validMoves = board.listValidMoves<Board>();
short bestScore = VALUE_MIN;
short movesCount = 0;

Stats::incrementNodesSearched();
Stats::incrementNodesGenerated(validMoves.size());

for (const Board &move : validMoves)
{
if (move.state == State::WINNER_WHITE || move.state == State::WINNER_BLACK)
Expand Down Expand Up @@ -244,8 +244,8 @@ short Search::quiescence(const Board &board, short alpha, const short beta)

const auto validMoves = board.listQuiescenceMoves();

if (Stats::enabled())
++Stats::nodesSearched;
Stats::incrementNodesSearched();
Stats::incrementNodesGenerated(validMoves.size());

for (const Board &move : validMoves)
{
Expand Down