Skip to content

Commit

Permalink
Make a place for canonical games strings (remove from universal_poker…
Browse files Browse the repository at this point in the history
… to avoid link errors when ACPC not compiled in)

PiperOrigin-RevId: 299208432
Change-Id: Icca0290192e2abdd5058931a595144125a5dd7a1
  • Loading branch information
DeepMind Technologies Ltd authored and open_spiel@google.com committed Mar 5, 2020
1 parent e5228fe commit d6d69e2
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 29 deletions.
2 changes: 2 additions & 0 deletions open_spiel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ set (BUILD_TESTING OFF)
enable_testing()

set (OPEN_SPIEL_CORE_FILES
canonical_game_strings.h
canonical_game_strings.cc
game_parameters.h
game_parameters.cc
spiel.h
Expand Down
40 changes: 40 additions & 0 deletions open_spiel/canonical_game_strings.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "open_spiel/canonical_game_strings.h"

#include <string>

#include "open_spiel/abseil-cpp/absl/strings/str_format.h"

namespace open_spiel {

std::string HunlGameString(const std::string &betting_abstraction) {
return absl::StrFormat(
"universal_poker(betting=nolimit,numPlayers=2,numRounds=4,blind=100 50,"
"firstPlayer=2 1 1 "
"1,numSuits=4,numRanks=13,numHoleCards=2,numBoardCards=0 3 "
"1 1,stack=20000 20000,bettingAbstraction=%s)",
betting_abstraction);
}

std::string HulhGameString(const std::string &betting_abstraction) {
return absl::StrFormat(
"universal_poker(betting=limit,numPlayers=2,numRounds=4,blind=100 50,"
"firstPlayer=2 1,numSuits=4,numRanks=13,numHoleCards=2,numBoardCards=0 3 "
"1 1,raiseSize=200 200 400 400,maxRaises=3 4 4 4,bettingAbstraction=%s)",
betting_abstraction);
}

} // namespace open_spiel
37 changes: 37 additions & 0 deletions open_spiel/canonical_game_strings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef THIRD_PARTY_OPEN_SPIEL_CANONICAL_GAME_STRINGS_H_
#define THIRD_PARTY_OPEN_SPIEL_CANONICAL_GAME_STRINGS_H_

#include <string>

// A place to store functions that return canonical game strings. These strings
// can sent to LoadGame to load the game.

namespace open_spiel {

// Returns the "canonical" definition of Heads-up No-limit Texas Hold'em and
// Heads-up Limit Texas Hold'em according to the ACPC:
// http://www.computerpokercompetition.org/.
// Valid values for betting_abstraction are "fc" for fold-call, and "fcpa" for
// fold, call, pot, all-in. These indicate the actions that are allowed. Note
// that in limit poker, "fcpa" is just the full game.
// The string returned can be passed directly to LoadGame.
std::string HunlGameString(const std::string &betting_abstraction);
std::string HulhGameString(const std::string &betting_abstraction);

} // namespace open_spiel

#endif // THIRD_PARTY_OPEN_SPIEL_SPIEL_H_
17 changes: 0 additions & 17 deletions open_spiel/games/universal_poker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@
namespace open_spiel {
namespace universal_poker {

std::string HunlGameString(const std::string &betting_abstraction) {
return absl::StrFormat(
"universal_poker(betting=nolimit,numPlayers=2,numRounds=4,blind=100 50,"
"firstPlayer=2 1 1 "
"1,numSuits=4,numRanks=13,numHoleCards=2,numBoardCards=0 3 "
"1 1,stack=20000 20000,bettingAbstraction=%s)",
betting_abstraction);
}

std::string HulhGameString(const std::string &betting_abstraction) {
return absl::StrFormat(
"universal_poker(betting=limit,numPlayers=2,numRounds=4,blind=100 50,"
"firstPlayer=2 1,numSuits=4,numRanks=13,numHoleCards=2,numBoardCards=0 3 "
"1 1,raiseSize=200 200 400 400,maxRaises=3 4 4 4,bettingAbstraction=%s)",
betting_abstraction);
}

const GameType kGameType{
/*short_name=*/"universal_poker",
/*long_name=*/"Universal Poker",
Expand Down
10 changes: 0 additions & 10 deletions open_spiel/games/universal_poker.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ class UniformRestrictedActions : public Policy {
std::vector<ActionType> actions_;
};

// Returns the "canonical" definition of Heads-up No-limit Texas Hold'em and
// Heads-up Limit Texas Hold'em according to the ACPC:
// http://www.computerpokercompetition.org/.
// Valid values for betting_abstraction are "fc" for fold-call, and "fcpa" for
// fold, call, pot, all-in. These indicate the actions that are allowed. Note
// that in limit poker, "fcpa" is just the full game.
// The string returned can be passed directly to LoadGame.
std::string HunlGameString(const std::string &betting_abstraction);
std::string HulhGameString(const std::string &betting_abstraction);

} // namespace universal_poker
} // namespace open_spiel

Expand Down
5 changes: 3 additions & 2 deletions open_spiel/python/pybind11/pyspiel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "open_spiel/algorithms/tabular_exploitability.h"
#include "open_spiel/algorithms/tensor_game_utils.h"
#include "open_spiel/algorithms/trajectories.h"
#include "open_spiel/canonical_game_strings.h"
#include "open_spiel/game_transforms/normal_form_extensive_game.h"
#include "open_spiel/game_transforms/turn_based_simultaneous_game.h"
#include "open_spiel/games/efg_game.h"
Expand Down Expand Up @@ -583,8 +584,8 @@ PYBIND11_MODULE(pyspiel, m) {
.def("record_batch",
&open_spiel::algorithms::TrajectoryRecorder::RecordBatch);

m.def("hulh_game_string", &open_spiel::universal_poker::HulhGameString);
m.def("hunl_game_string", &open_spiel::universal_poker::HunlGameString);
m.def("hulh_game_string", &open_spiel::HulhGameString);
m.def("hunl_game_string", &open_spiel::HunlGameString);
m.def("create_matrix_game",
py::overload_cast<const std::string&, const std::string&,
const std::vector<std::string>&,
Expand Down

0 comments on commit d6d69e2

Please sign in to comment.