Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when loading game with known issues #1163

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions open_spiel/spiel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ GameRegisterer::GameRegisterer(const GameType& game_type, CreateFunc creator) {

std::shared_ptr<const Game> GameRegisterer::CreateByName(
const std::string& short_name, const GameParameters& params) {
// Check if it's a game with a known issue. If so, output a warning.
auto known_issues_iter = absl::c_find(GamesWithKnownIssues(), short_name);
if (known_issues_iter != GamesWithKnownIssues().end()) {
std::cerr << "Warning! This game has known issues. Please see the games "
<< "list on github or the code for details."
<< std::endl;
}

// Find the factory for this game and load it.
auto iter = factories().find(short_name);
if (iter == factories().end()) {
SpielFatalError(absl::StrCat("Unknown game '", short_name,
Expand All @@ -159,6 +168,10 @@ std::vector<std::string> GameRegisterer::RegisteredNames() {
}
return names;
}

const std::vector<std::string> GameRegisterer::GamesWithKnownIssues() {
return {"quoridor", "rbc", "universal_poker"};
}

std::vector<GameType> GameRegisterer::RegisteredGames() {
std::vector<GameType> games;
Expand Down
2 changes: 2 additions & 0 deletions open_spiel/spiel.h
Original file line number Diff line number Diff line change
Expand Up @@ -1056,11 +1056,13 @@ class GameRegisterer {
static std::shared_ptr<const Game> CreateByName(const std::string& short_name,
const GameParameters& params);

static const std::vector<std::string> GamesWithKnownIssues();
static std::vector<std::string> RegisteredNames();
static std::vector<GameType> RegisteredGames();
static bool IsValidName(const std::string& short_name);
static void RegisterGame(const GameType& game_type, CreateFunc creator);


private:
// Returns a "global" map of registrations (i.e. an object that lives from
// initialization to the end of the program). Note that we do not just use
Expand Down