From 9a27b78845c0d7c5a46c1a270da9af6dde3b3784 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Mon, 20 Sep 2021 07:19:39 -0600 Subject: [PATCH] Remove State::UndoAction from catch and cliff_walking. Properly implementing this function requires significant changes to the implementation (extra nontrivial book-keeping). PiperOrigin-RevId: 397732772 Change-Id: I7f5b5d4d1bcb94cf39e7f2b699f2b21259f6b0a9 --- open_spiel/games/catch.cc | 16 ---------------- open_spiel/games/catch.h | 1 - open_spiel/games/catch_test.cc | 1 - open_spiel/games/cliff_walking.cc | 24 ------------------------ open_spiel/games/cliff_walking.h | 1 - open_spiel/games/cliff_walking_test.cc | 1 - 6 files changed, 44 deletions(-) diff --git a/open_spiel/games/catch.cc b/open_spiel/games/catch.cc index 8333496e47..0b1d41a1d2 100644 --- a/open_spiel/games/catch.cc +++ b/open_spiel/games/catch.cc @@ -165,22 +165,6 @@ void CatchState::ObservationTensor(Player player, } } -void CatchState::UndoAction(Player player, Action move) { - history_.pop_back(); - --move_number_; - if (player == kChancePlayerId) { - initialized_ = false; - ball_row_ = -1; - ball_col_ = -1; - paddle_col_ = -1; - } else { - int direction = move - 1; - paddle_col_ = - std::min(std::max(paddle_col_ - direction, 0), num_columns_ - 1); - --ball_row_; - } -} - std::unique_ptr CatchState::Clone() const { return std::unique_ptr(new CatchState(*this)); } diff --git a/open_spiel/games/catch.h b/open_spiel/games/catch.h index aff53c75b5..e68ee55cd6 100644 --- a/open_spiel/games/catch.h +++ b/open_spiel/games/catch.h @@ -73,7 +73,6 @@ class CatchState : public State { void ObservationTensor(Player player, absl::Span values) const override; std::unique_ptr Clone() const override; - void UndoAction(Player player, Action move) override; std::vector LegalActions() const override; ActionsAndProbs ChanceOutcomes() const override; CellState BoardAt(int row, int column) const; diff --git a/open_spiel/games/catch_test.cc b/open_spiel/games/catch_test.cc index 6f4daea13b..5fe7c87db0 100644 --- a/open_spiel/games/catch_test.cc +++ b/open_spiel/games/catch_test.cc @@ -29,7 +29,6 @@ void BasicCatchTests() { testing::LoadGameTest("catch"); testing::ChanceOutcomesTest(*LoadGame("catch")); testing::RandomSimTest(*LoadGame("catch"), 100); - testing::RandomSimTestWithUndo(*LoadGame("catch"), 1); } void GetAllStatesTest() { diff --git a/open_spiel/games/cliff_walking.cc b/open_spiel/games/cliff_walking.cc index 9d43f3f222..416af367b3 100644 --- a/open_spiel/games/cliff_walking.cc +++ b/open_spiel/games/cliff_walking.cc @@ -157,30 +157,6 @@ void CliffWalkingState::InformationStateTensor(Player player, } } -void CliffWalkingState::UndoAction(Player player, Action move) { - switch (move) { - case RIGHT: - --player_col_; - break; - case UP: - ++player_row_; - break; - case LEFT: - ++player_col_; - break; - case DOWN: - --player_row_; - break; - default: - SpielFatalError("Unexpected action"); - } - player_row_ = std::min(std::max(player_row_, 0), height_ - 1); - player_col_ = std::min(std::max(player_col_, 0), width_ - 1); - --time_counter_; - history_.pop_back(); - --move_number_; -} - std::unique_ptr CliffWalkingState::Clone() const { return std::unique_ptr(new CliffWalkingState(*this)); } diff --git a/open_spiel/games/cliff_walking.h b/open_spiel/games/cliff_walking.h index b661a1d4ff..2a2123b3d4 100644 --- a/open_spiel/games/cliff_walking.h +++ b/open_spiel/games/cliff_walking.h @@ -92,7 +92,6 @@ class CliffWalkingState : public State { void InformationStateTensor(Player player, absl::Span values) const override; std::unique_ptr Clone() const override; - void UndoAction(Player player, Action move) override; std::vector LegalActions() const override; protected: diff --git a/open_spiel/games/cliff_walking_test.cc b/open_spiel/games/cliff_walking_test.cc index 8d5fc6b144..caa96f7c5f 100644 --- a/open_spiel/games/cliff_walking_test.cc +++ b/open_spiel/games/cliff_walking_test.cc @@ -28,7 +28,6 @@ void BasicCliffWalkingTests() { testing::LoadGameTest("cliff_walking"); testing::NoChanceOutcomesTest(*LoadGame("cliff_walking")); testing::RandomSimTest(*LoadGame("cliff_walking"), 100); - testing::RandomSimTestWithUndo(*LoadGame("cliff_walking"), 1); } } // namespace