Skip to content

Commit

Permalink
Expose IsRepetitionDraw() for chess states in Python.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 643339231
Change-Id: I943ff69761a89342c4eae13c795a4294809dab77
  • Loading branch information
lanctot committed Jul 15, 2024
1 parent 5c57b86 commit 6341ae2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions open_spiel/games/chess/chess.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ class ChessState : public State {

std::string Serialize() const override;

protected:
void DoApplyAction(Action action) override;

private:
// Draw can be claimed under the FIDE 3-fold repetition rule (the current
// board position has already appeared twice in the history).
bool IsRepetitionDraw() const;

protected:
void DoApplyAction(Action action) override;

private:
// Calculates legal actions and caches them. This is separate from
// LegalActions() as there are a number of other methods that need the value
// of LegalActions. This is a separate method as it's called from
Expand Down
3 changes: 2 additions & 1 deletion open_spiel/python/pybind11/games_chess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ void open_spiel::init_pyspiel_games_chess(py::module& m) {
py::classh<ChessState, State>(m, "ChessState")
.def("board", py::overload_cast<>(&ChessState::Board))
.def("debug_string", &ChessState::DebugString)
.def("parse_move_to_action", &ChessState::ParseMoveToAction)
.def("is_repetition_draw", &ChessState::IsRepetitionDraw)
.def("moves_history", py::overload_cast<>(&ChessState::MovesHistory))
.def("parse_move_to_action", &ChessState::ParseMoveToAction)
// Pickle support
.def(py::pickle(
[](const ChessState& state) { // __getstate__
Expand Down

0 comments on commit 6341ae2

Please sign in to comment.