Skip to content

Commit

Permalink
Expose cut threshold when calculating CCE dist.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 377903873
Change-Id: I184688a45743081b3641874fa99ce4a218788b3e
  • Loading branch information
lukemarris authored and open_spiel@google.com committed Jun 13, 2021
1 parent 5c9e444 commit 56e7fe7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
12 changes: 8 additions & 4 deletions open_spiel/algorithms/corr_dist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ double CCEDist(const Game& game, const NormalFormCorrelationDevice& mu) {
}

CorrDistInfo CCEDist(
const Game& game, const CorrelationDevice& mu, int player) {
const Game& game, const CorrelationDevice& mu, int player,
const float prob_cut_threshold) {
// Check for proper probability distribution.
CheckCorrelationDeviceProbDist(mu);
CorrDistConfig config;
Expand All @@ -273,7 +274,7 @@ CorrDistInfo CCEDist(
CCETabularPolicy policy;
std::unique_ptr<State> root = cce_game->NewInitialState();
TabularBestResponse best_response(
*cce_game, player, &policy);
*cce_game, player, &policy, prob_cut_threshold);
// Do not populate on policy values to save unnecessary computation.
// dist_info.on_policy_values[0] = ExpectedReturns(
// *root, policy, -1, false)[player];
Expand All @@ -288,7 +289,9 @@ CorrDistInfo CCEDist(
return dist_info;
}

CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu) {
CorrDistInfo CCEDist(
const Game& game, const CorrelationDevice& mu,
const float prob_cut_threshold) {
// Check for proper probability distribution.
CheckCorrelationDeviceProbDist(mu);
CorrDistConfig config;
Expand All @@ -314,7 +317,8 @@ CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu) {

std::unique_ptr<State> root = cce_game->NewInitialState();
for (auto p = Player{0}; p < cce_game->NumPlayers(); ++p) {
TabularBestResponse best_response(*cce_game, p, &policy);
TabularBestResponse best_response(
*cce_game, p, &policy, prob_cut_threshold);
dist_info.best_response_values[p] = best_response.Value(*root);
dist_info.best_response_policies[p] = best_response.GetBestResponsePolicy();
}
Expand Down
6 changes: 4 additions & 2 deletions open_spiel/algorithms/corr_dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ struct CorrDistInfo {
// determines which policies the opponents follow (never revealed). Note that
// the policies in this correlation device *can* be mixed. If values is
// non-null, then it is filled with the deviation incentive of each player.
CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu);
CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu, int player);
CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu,
const float prob_cut_threshold = -1.0);
CorrDistInfo CCEDist(const Game& game, const CorrelationDevice& mu, int player,
const float prob_cut_threshold = -1.0);

// Distance to a correlated equilibrium in an extensive-form game. Builds a
// simpler auxiliary game similar to the *FCE ones where there is a chance node
Expand Down
15 changes: 11 additions & 4 deletions open_spiel/python/pybind11/algorithms_corr_dist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,21 @@ void init_pyspiel_algorithms_corr_dist(py::module& m) {
&CorrDistInfo::conditional_best_response_policies);

m.def("cce_dist",
py::overload_cast<const Game&, const CorrelationDevice&, int>(
py::overload_cast<const Game&, const CorrelationDevice&, int, float>(
&open_spiel::algorithms::CCEDist),
"Returns a player's distance to a coarse-correlated equilibrium.");
"Returns a player's distance to a coarse-correlated equilibrium.",
py::arg("game"),
py::arg("correlation_device"),
py::arg("player"),
py::arg("prob_cut_threshold") = -1.0);

m.def("cce_dist",
py::overload_cast<const Game&, const CorrelationDevice&>(
py::overload_cast<const Game&, const CorrelationDevice&, float>(
&open_spiel::algorithms::CCEDist),
"Returns the distance to a coarse-correlated equilibrium.");
"Returns the distance to a coarse-correlated equilibrium.",
py::arg("game"),
py::arg("correlation_device"),
py::arg("prob_cut_threshold") = -1.0);

m.def("ce_dist",
py::overload_cast<const Game&, const CorrelationDevice&>(
Expand Down

0 comments on commit 56e7fe7

Please sign in to comment.