From 6341ae2c40165f7364ef4d0971a0c052c76d9ae8 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Fri, 14 Jun 2024 14:29:55 +0000 Subject: [PATCH] Expose IsRepetitionDraw() for chess states in Python. PiperOrigin-RevId: 643339231 Change-Id: I943ff69761a89342c4eae13c795a4294809dab77 --- open_spiel/games/chess/chess.h | 8 ++++---- open_spiel/python/pybind11/games_chess.cc | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/open_spiel/games/chess/chess.h b/open_spiel/games/chess/chess.h index 5d89c0d0bc..08424f5909 100644 --- a/open_spiel/games/chess/chess.h +++ b/open_spiel/games/chess/chess.h @@ -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 diff --git a/open_spiel/python/pybind11/games_chess.cc b/open_spiel/python/pybind11/games_chess.cc index 69a24fbc84..8649f33499 100644 --- a/open_spiel/python/pybind11/games_chess.cc +++ b/open_spiel/python/pybind11/games_chess.cc @@ -91,8 +91,9 @@ void open_spiel::init_pyspiel_games_chess(py::module& m) { py::classh(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__