Skip to content

Commit

Permalink
Fix catch observation in initial state.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 267156470
Change-Id: Idd6f73f083830328688e19225ea8501f7ba3f160
  • Loading branch information
DeepMind Technologies Ltd authored and elkhrt committed Sep 4, 2019
1 parent 28a8120 commit aa13ad9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions open_spiel/games/catch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ void CatchState::ObservationAsNormalizedVector(

values->resize(game_.NumRows() * game_.NumColumns());
std::fill(values->begin(), values->end(), 0.);
(*values)[ball_row_ * game_.NumColumns() + ball_col_] = 1.0;
(*values)[(game_.NumRows() - 1) * game_.NumColumns() + paddle_col_] = 1.0;
if (initialized_) {
(*values)[ball_row_ * game_.NumColumns() + ball_col_] = 1.0;
(*values)[(game_.NumRows() - 1) * game_.NumColumns() + paddle_col_] = 1.0;
}
}

void CatchState::InformationStateAsNormalizedVector(
Expand All @@ -171,10 +173,13 @@ void CatchState::InformationStateAsNormalizedVector(

values->resize(game_.NumColumns() + kNumActions * game_.NumRows());
std::fill(values->begin(), values->end(), 0.);
(*values)[ball_col_] = 1;
int offset = history_.size() - ball_row_ - 1;
for (int i = 0; i < ball_row_; i++) {
(*values)[game_.NumColumns() + i * kNumActions + history_[offset + i]] = 1;
if (initialized_) {
(*values)[ball_col_] = 1;
int offset = history_.size() - ball_row_ - 1;
for (int i = 0; i < ball_row_; i++) {
(*values)[game_.NumColumns() + i * kNumActions + history_[offset + i]] =
1;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion open_spiel/integration_tests/playthroughs/catch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CurrentPlayer() = -1
InformationState(0) = ""
InformationStateAsNormalizedVector(0) = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
Observation(0) = ".....\n.....\n.....\n.....\n.....\n.....\n.....\n.....\n.....\n.....\n"
ObservationAsNormalizedVector(0) = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]
ObservationAsNormalizedVector(0) = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
ChanceOutcomes() = [{0, 0.200000000000}, {1, 0.200000000000}, {2, 0.200000000000}, {3, 0.200000000000}, {4, 0.200000000000}]
LegalActions() = [0, 1, 2, 3, 4]
StringLegalActions() = ["Initialized ball to 0", "Initialized ball to 1", "Initialized ball to 2", "Initialized ball to 3", "Initialized ball to 4"]
Expand Down

0 comments on commit aa13ad9

Please sign in to comment.