Skip to content

Commit

Permalink
feat: add nps tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Jul 29, 2023
1 parent dfea26d commit 6024d0b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Options:
-rounds N
-sprt elo0=ELO0 elo1=ELO1 alpha=ALPHA beta=BETA
-srand SEED
-pgnout notation=NOTATION file=FILE nodes=true seldepth=true
-pgnout notation=NOTATION file=FILE nodes=true seldepth=true nps=true
NOTATION defaults to san, alternatively you can choose lan or uci, default file output is
fast-chess.pgn.
fast-chess.pgn.
If you pass nodes or seldepth as true, the pgn will contain the nodes and/or seldepth in the move comment.
-log file=NAME
Expand Down
2 changes: 2 additions & 0 deletions src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class Pgnout : public Option {
argument_data.game_options.pgn.track_nodes = true;
} else if (key == "seldepth") {
argument_data.game_options.pgn.track_seldepth = true;
} else if (key == "nps") {
argument_data.game_options.pgn.track_nps = true;
} else if (key == "notation") {
if (value == "san") {
argument_data.game_options.pgn.notation = NotationType::SAN;
Expand Down
1 change: 1 addition & 0 deletions src/matchmaking/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void Match::addMoveData(Participant& player, int64_t measured_time) {
const auto score_type = player.engine.lastScoreType();
const auto info = player.engine.lastInfo();

move_data.nps = str_utils::findElement<int>(info, "nps").value_or(0);
move_data.depth = str_utils::findElement<int>(info, "depth").value_or(0);
move_data.seldepth = str_utils::findElement<int>(info, "seldepth").value_or(0);
move_data.nodes = str_utils::findElement<uint64_t>(info, "nodes").value_or(0);
Expand Down
1 change: 1 addition & 0 deletions src/matchmaking/types/match_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct MoveData {
int seldepth = 0;
int depth = 0;
int score = 0;
int nps = 0;

MoveData(std::string _move, std::string _score_string, int64_t _elapsed_millis, int _depth,
int _seldepth, int _score, int _nodes)
Expand Down
11 changes: 6 additions & 5 deletions src/pgn_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ void PgnBuilder::addMove(chess::Board &board, const MoveData &move, std::size_t
ss << (move_number % 2 == 1 ? std::to_string(move_number / 2 + 1) + ". " : "");
ss << moveNotation(board, move.move);

ss << addComment((move.score_string + "/" + std::to_string(move.depth)),
formatTime(move.elapsed_millis),
game_options_.pgn.track_nodes ? std::to_string(move.nodes) : "",
game_options_.pgn.track_seldepth ? std::to_string(move.seldepth) : "",
match_.moves.size() == move_number ? match_.internal_reason : "");
ss << addComment(
(move.score_string + "/" + std::to_string(move.depth)), formatTime(move.elapsed_millis),
game_options_.pgn.track_nodes ? "nodes," + std::to_string(move.nodes) : "",
game_options_.pgn.track_seldepth ? "seldepth, " + std::to_string(move.seldepth) : "",
game_options_.pgn.track_nps ? "nps, " + std::to_string(move.nps) : "",
match_.moves.size() == move_number ? match_.internal_reason : "");

moves_.emplace_back(ss.str());
}
Expand Down

0 comments on commit 6024d0b

Please sign in to comment.