Skip to content

Commit

Permalink
Also call UpdateDistribution with empty vector if DistributionSupport…
Browse files Browse the repository at this point in the history
… is empty.

This is a corner case that was correctly taken into account in the previous change.
Also add some printing to help debugging.

PiperOrigin-RevId: 447040459
Change-Id: Ibda042218396983d45adcc6cbe1b205c2ba77886
  • Loading branch information
TheoCabannes authored and lanctot committed May 9, 2022
1 parent c90e925 commit 78bef84
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions open_spiel/examples/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ int main(int argc, char** argv) {
state->ApplyAction(action);
} else if (state->IsMeanFieldNode()) {
int num_states_distribution = state->DistributionSupport().size();
if (num_states_distribution) {
state->UpdateDistribution(std::vector<double>(
num_states_distribution, 1.0 / num_states_distribution));
}
state->UpdateDistribution(std::vector<double>(
num_states_distribution,
num_states_distribution > 0 ? 1.0 / num_states_distribution : 1.0));
std::cerr << "Call update distribution on a uniform distribution of "
<< num_states_distribution << " states (length of "
<< "DistributionSupport" << std::endl;
} else if (state->IsSimultaneousNode()) {
// open_spiel::Players choose simultaneously?
std::vector<open_spiel::Action> joint_action;
Expand Down

0 comments on commit 78bef84

Please sign in to comment.