Skip to content

Commit

Permalink
Remove State::UndoAction from catch and cliff_walking. Properly imple…
Browse files Browse the repository at this point in the history
…menting this function requires significant changes to the implementation (extra nontrivial book-keeping).

PiperOrigin-RevId: 397732772
Change-Id: I7f5b5d4d1bcb94cf39e7f2b699f2b21259f6b0a9
  • Loading branch information
lanctot committed Sep 20, 2021
1 parent a5b252a commit 9a27b78
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 44 deletions.
16 changes: 0 additions & 16 deletions open_spiel/games/catch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<State> CatchState::Clone() const {
return std::unique_ptr<State>(new CatchState(*this));
}
Expand Down
1 change: 0 additions & 1 deletion open_spiel/games/catch.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class CatchState : public State {
void ObservationTensor(Player player,
absl::Span<float> values) const override;
std::unique_ptr<State> Clone() const override;
void UndoAction(Player player, Action move) override;
std::vector<Action> LegalActions() const override;
ActionsAndProbs ChanceOutcomes() const override;
CellState BoardAt(int row, int column) const;
Expand Down
1 change: 0 additions & 1 deletion open_spiel/games/catch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
24 changes: 0 additions & 24 deletions open_spiel/games/cliff_walking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<State> CliffWalkingState::Clone() const {
return std::unique_ptr<State>(new CliffWalkingState(*this));
}
Expand Down
1 change: 0 additions & 1 deletion open_spiel/games/cliff_walking.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class CliffWalkingState : public State {
void InformationStateTensor(Player player,
absl::Span<float> values) const override;
std::unique_ptr<State> Clone() const override;
void UndoAction(Player player, Action move) override;
std::vector<Action> LegalActions() const override;

protected:
Expand Down
1 change: 0 additions & 1 deletion open_spiel/games/cliff_walking_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a27b78

Please sign in to comment.