├── .github
└── workflows
│ ├── actions.yml
│ └── wheels.yml
├── .gitignore
├── CONTRIBUTING.md
├── Dockerfile.base
├── Dockerfile.jupyter
├── LICENSE
├── MANIFEST.in
├── README.md
├── docs
├── Makefile
├── _static
│ ├── OpenSpielB.png
│ ├── alpha_sweep_plots.png
│ ├── example_multi_population_game_rankings.png
│ ├── green_circ10.png
│ ├── markov_chain_visualization.png
│ ├── passing.svg
│ └── public_tree_kuhn.png
├── algorithms.md
├── alpha_rank.md
├── alpha_zero.md
├── api_reference.md
├── api_reference
│ ├── game_action_to_string.md
│ ├── game_deserialize_game_and_state.md
│ ├── game_deserialize_state.md
│ ├── game_information_state_tensor_shape_size.md
│ ├── game_max_chance_outcomes.md
│ ├── game_max_game_length.md
│ ├── game_max_min_utility.md
│ ├── game_new_initial_state.md
│ ├── game_num_distinct_actions.md
│ ├── game_observation_tensor_shape_size.md
│ ├── game_serialize_game_and_state.md
│ ├── load_game.md
│ ├── registered_names.md
│ ├── state_action_to_string.md
│ ├── state_apply_action.md
│ ├── state_chance_outcomes.md
│ ├── state_current_player.md
│ ├── state_history.md
│ ├── state_information_state_string.md
│ ├── state_information_state_tensor.md
│ ├── state_is_chance_node.md
│ ├── state_is_simultaneous_node.md
│ ├── state_is_terminal.md
│ ├── state_legal_actions.md
│ ├── state_observation_string.md
│ ├── state_observation_tensor.md
│ ├── state_returns.md
│ ├── state_rewards.md
│ └── state_serialize.md
├── authors.md
├── concepts.md
├── conf.py
├── contributing.md
├── developer_guide.md
├── fix_table_links.sh
├── games.md
├── index.rst
├── install.md
├── intro.md
├── julia.md
├── library.md
├── requirements.readthedocs.txt
└── windows.md
├── install.sh
├── open_spiel
├── CMakeLists.txt
├── __init__.py
├── action_view.cc
├── action_view.h
├── algorithms
│ ├── CMakeLists.txt
│ ├── alpha_zero_torch
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── alpha_zero.cc
│ │ ├── alpha_zero.h
│ │ ├── device_manager.h
│ │ ├── model.cc
│ │ ├── model.h
│ │ ├── model_test.cc
│ │ ├── vpevaluator.cc
│ │ ├── vpevaluator.h
│ │ ├── vpnet.cc
│ │ ├── vpnet.h
│ │ └── vpnet_test.cc
│ ├── best_response.cc
│ ├── best_response.h
│ ├── best_response_test.cc
│ ├── cfr.cc
│ ├── cfr.h
│ ├── cfr_br.cc
│ ├── cfr_br.h
│ ├── cfr_br_test.cc
│ ├── cfr_test.cc
│ ├── corr_dev_builder.cc
│ ├── corr_dev_builder.h
│ ├── corr_dev_builder_test.cc
│ ├── corr_dist.cc
│ ├── corr_dist.h
│ ├── corr_dist
│ │ ├── afcce.cc
│ │ ├── afcce.h
│ │ ├── afce.cc
│ │ ├── afce.h
│ │ ├── cce.cc
│ │ ├── cce.h
│ │ ├── ce.cc
│ │ ├── ce.h
│ │ ├── efcce.cc
│ │ ├── efcce.h
│ │ ├── efce.cc
│ │ └── efce.h
│ ├── corr_dist_test.cc
│ ├── deterministic_policy.cc
│ ├── deterministic_policy.h
│ ├── deterministic_policy_test.cc
│ ├── dqn_torch
│ │ ├── CMakeLists.txt
│ │ ├── dqn.cc
│ │ ├── dqn.h
│ │ ├── dqn_torch_test.cc
│ │ ├── simple_nets.cc
│ │ └── simple_nets.h
│ ├── evaluate_bots.cc
│ ├── evaluate_bots.h
│ ├── evaluate_bots_test.cc
│ ├── expected_returns.cc
│ ├── expected_returns.h
│ ├── external_sampling_mccfr.cc
│ ├── external_sampling_mccfr.h
│ ├── external_sampling_mccfr_test.cc
│ ├── fsicfr.cc
│ ├── fsicfr.h
│ ├── get_all_histories.cc
│ ├── get_all_histories.h
│ ├── get_all_histories_test.cc
│ ├── get_all_infostates.cc
│ ├── get_all_infostates.h
│ ├── get_all_states.cc
│ ├── get_all_states.h
│ ├── get_all_states_test.cc
│ ├── get_legal_actions_map.cc
│ ├── get_legal_actions_map.h
│ ├── get_legal_actions_map_test.cc
│ ├── history_tree.cc
│ ├── history_tree.h
│ ├── history_tree_test.cc
│ ├── infostate_tree.cc
│ ├── infostate_tree.h
│ ├── infostate_tree_test.cc
│ ├── is_mcts.cc
│ ├── is_mcts.h
│ ├── is_mcts_test.cc
│ ├── matrix_game_utils.cc
│ ├── matrix_game_utils.h
│ ├── matrix_game_utils_test.cc
│ ├── maxn.cc
│ ├── maxn.h
│ ├── mcts.cc
│ ├── mcts.h
│ ├── mcts_test.cc
│ ├── minimax.cc
│ ├── minimax.h
│ ├── minimax_test.cc
│ ├── nfg_writer.cc
│ ├── nfg_writer.h
│ ├── nfg_writer_test.cc
│ ├── observation_history.cc
│ ├── observation_history.h
│ ├── observation_history_test.cc
│ ├── oos.cc
│ ├── oos.h
│ ├── oos_test.cc
│ ├── ortools
│ │ ├── CMakeLists.txt
│ │ ├── lp_solver.cc
│ │ ├── lp_solver.h
│ │ ├── lp_solver_test.cc
│ │ ├── sequence_form_lp.cc
│ │ ├── sequence_form_lp.h
│ │ ├── sequence_form_lp_test.cc
│ │ └── simple_lp_solver_example.cc
│ ├── outcome_sampling_mccfr.cc
│ ├── outcome_sampling_mccfr.h
│ ├── outcome_sampling_mccfr_test.cc
│ ├── policy_iteration.cc
│ ├── policy_iteration.h
│ ├── state_distribution.cc
│ ├── state_distribution.h
│ ├── state_distribution_test.cc
│ ├── tabular_best_response_mdp.cc
│ ├── tabular_best_response_mdp.h
│ ├── tabular_best_response_mdp_test.cc
│ ├── tabular_exploitability.cc
│ ├── tabular_exploitability.h
│ ├── tabular_exploitability_test.cc
│ ├── tabular_q_learning.cc
│ ├── tabular_q_learning.h
│ ├── tabular_q_learning_test.cc
│ ├── tabular_sarsa.cc
│ ├── tabular_sarsa.h
│ ├── tabular_sarsa_test.cc
│ ├── tensor_game_utils.cc
│ ├── tensor_game_utils.h
│ ├── tensor_game_utils_test.cc
│ ├── trajectories.cc
│ ├── trajectories.h
│ ├── trajectories_test.cc
│ ├── value_iteration.cc
│ └── value_iteration.h
├── bots
│ ├── CMakeLists.txt
│ ├── gin_rummy
│ │ ├── CMakeLists.txt
│ │ ├── simple_gin_rummy_bot.cc
│ │ ├── simple_gin_rummy_bot.h
│ │ ├── simple_gin_rummy_bot_example.cc
│ │ └── simple_gin_rummy_bot_test.cc
│ ├── human
│ │ ├── CMakeLists.txt
│ │ ├── human_bot.cc
│ │ ├── human_bot.h
│ │ └── human_bot_test.cc
│ ├── pimc_bot.cc
│ ├── pimc_bot.h
│ ├── pimc_bot_test.cc
│ ├── roshambo
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── roshambo_bot.cc
│ │ ├── roshambo_bot.h
│ │ └── roshambo_bot_test.cc
│ ├── uci
│ │ ├── CMakeLists.txt
│ │ ├── random_uci_bot.cc
│ │ ├── uci_bot.cc
│ │ ├── uci_bot.h
│ │ └── uci_bot_test.cc
│ └── xinxin
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── xinxin_bot.cc
│ │ ├── xinxin_bot.h
│ │ ├── xinxin_bot_test.cc
│ │ ├── xinxin_bot_test.py
│ │ ├── xinxin_game_generator.cc
│ │ ├── xinxin_pybind11.cc
│ │ └── xinxin_pybind11.h
├── canonical_game_strings.cc
├── canonical_game_strings.h
├── colabs
│ ├── CFR_and_REINFORCE.ipynb
│ ├── OpenSpielTutorial.ipynb
│ ├── crowd_modelling_4rooms_MFGsurvey.ipynb
│ ├── install_open_spiel.ipynb
│ ├── rcfr_pytorch.ipynb
│ ├── research_dqn_pytorch.ipynb
│ ├── research_nfsp_tf_pt.ipynb
│ └── test_universal_poker.ipynb
├── data
│ └── paper_data
│ │ ├── README.md
│ │ ├── pbe_rrps
│ │ ├── README.md
│ │ └── bot_table_file.txt
│ │ ├── response_graph_ucb
│ │ └── soccer.txt
│ │ └── routing_game_experiments
│ │ ├── Experiments.ipynb
│ │ ├── readme.md
│ │ └── utils.py
├── evaluation
│ ├── CMakeLists.txt
│ ├── soft_condorcet_optimization.cc
│ ├── soft_condorcet_optimization.h
│ └── soft_condorcet_optimization_test.cc
├── examples
│ ├── CMakeLists.txt
│ ├── alpha_zero_torch_example.cc
│ ├── alpha_zero_torch_game_example.cc
│ ├── benchmark_game.cc
│ ├── cfr_example.cc
│ ├── cfr_multi_equilibria_example.cc
│ ├── count_all_states.cc
│ ├── dqn_torch_example.cc
│ ├── example.cc
│ ├── fsicfr_liars_dice.cc
│ ├── gtp.cc
│ ├── imperfect_recall_mccfr.cc
│ ├── is_mcts_gwhist.cc
│ ├── matrix_example.cc
│ ├── mcts_example.cc
│ ├── minimax_example.cc
│ ├── policy_iteration_example.cc
│ ├── sbr_blotto
│ │ ├── fictitious_play.cc
│ │ ├── fictitious_play.h
│ │ └── sbr_blotto_main.cc
│ ├── shared_library_example.cc
│ ├── tabular_q_learning_example.cc
│ ├── tabular_sarsa_example.cc
│ ├── universal_poker_mccfr_acpc_gamedef_example.cc
│ └── value_iteration_example.cc
├── game_parameters.cc
├── game_parameters.h
├── game_transforms
│ ├── CMakeLists.txt
│ ├── add_noise.cc
│ ├── add_noise.h
│ ├── add_noise_test.cc
│ ├── cached_tree.cc
│ ├── cached_tree.h
│ ├── cached_tree_test.cc
│ ├── coop_to_1p.cc
│ ├── coop_to_1p.h
│ ├── coop_to_1p_test.cc
│ ├── efg_writer.cc
│ ├── efg_writer.h
│ ├── efg_writer_test.cc
│ ├── game_wrapper.h
│ ├── misere.cc
│ ├── misere.h
│ ├── misere_test.cc
│ ├── normal_form_extensive_game.cc
│ ├── normal_form_extensive_game.h
│ ├── normal_form_extensive_game_test.cc
│ ├── repeated_game.cc
│ ├── repeated_game.h
│ ├── repeated_game_test.cc
│ ├── restricted_nash_response.cc
│ ├── restricted_nash_response.h
│ ├── restricted_nash_response_test.cc
│ ├── start_at.cc
│ ├── start_at.h
│ ├── start_at_test.cc
│ ├── turn_based_simultaneous_game.cc
│ ├── turn_based_simultaneous_game.h
│ ├── turn_based_simultaneous_game_test.cc
│ ├── zerosum.cc
│ ├── zerosum.h
│ └── zerosum_test.cc
├── games
│ ├── CMakeLists.txt
│ ├── amazons
│ │ ├── amazons.cc
│ │ ├── amazons.h
│ │ └── amazons_test.cc
│ ├── backgammon
│ │ ├── backgammon.cc
│ │ ├── backgammon.h
│ │ └── backgammon_test.cc
│ ├── bargaining
│ │ ├── bargaining.cc
│ │ ├── bargaining.h
│ │ ├── bargaining_instance_generator.cc
│ │ ├── bargaining_instances1000.cc
│ │ ├── bargaining_instances1000.txt
│ │ └── bargaining_test.cc
│ ├── battleship
│ │ ├── battleship.cc
│ │ ├── battleship.h
│ │ ├── battleship_test.cc
│ │ ├── battleship_types.cc
│ │ └── battleship_types.h
│ ├── blackjack
│ │ ├── blackjack.cc
│ │ ├── blackjack.h
│ │ └── blackjack_test.cc
│ ├── blotto
│ │ ├── blotto.cc
│ │ ├── blotto.h
│ │ └── blotto_test.cc
│ ├── breakthrough
│ │ ├── breakthrough.cc
│ │ ├── breakthrough.h
│ │ └── breakthrough_test.cc
│ ├── bridge
│ │ ├── bridge.cc
│ │ ├── bridge.h
│ │ ├── bridge_scoring.cc
│ │ ├── bridge_scoring.h
│ │ ├── bridge_test.cc
│ │ ├── bridge_uncontested_bidding.cc
│ │ └── bridge_uncontested_bidding.h
│ ├── catch
│ │ ├── catch.cc
│ │ ├── catch.h
│ │ └── catch_test.cc
│ ├── checkers
│ │ ├── checkers.cc
│ │ ├── checkers.h
│ │ └── checkers_test.cc
│ ├── chess
│ │ ├── chess.cc
│ │ ├── chess.h
│ │ ├── chess960_starting_positions.cc
│ │ ├── chess_board.cc
│ │ ├── chess_board.h
│ │ ├── chess_common.cc
│ │ ├── chess_common.h
│ │ └── chess_test.cc
│ ├── cliff_walking
│ │ ├── cliff_walking.cc
│ │ ├── cliff_walking.h
│ │ └── cliff_walking_test.cc
│ ├── clobber
│ │ ├── clobber.cc
│ │ ├── clobber.h
│ │ └── clobber_test.cc
│ ├── coin_game
│ │ ├── coin_game.cc
│ │ ├── coin_game.h
│ │ └── coin_game_test.cc
│ ├── colored_trails
│ │ ├── boards100.txt
│ │ ├── colored_trails.cc
│ │ ├── colored_trails.h
│ │ ├── colored_trails_board_generator.cc
│ │ ├── colored_trails_test.cc
│ │ └── colored_trails_utils.cc
│ ├── connect_four
│ │ ├── connect_four.cc
│ │ ├── connect_four.h
│ │ └── connect_four_test.cc
│ ├── coop_box_pushing
│ │ ├── coop_box_pushing.cc
│ │ ├── coop_box_pushing.h
│ │ └── coop_box_pushing_test.cc
│ ├── coordinated_mp
│ │ ├── coordinated_mp.cc
│ │ ├── coordinated_mp.h
│ │ └── coordinated_mp_test.cc
│ ├── crazy_eights
│ │ ├── crazy_eights.cc
│ │ ├── crazy_eights.h
│ │ └── crazy_eights_test.cc
│ ├── cribbage
│ │ ├── cribbage.cc
│ │ ├── cribbage.h
│ │ └── cribbage_test.cc
│ ├── cursor_go
│ │ ├── cursor_go.cc
│ │ ├── cursor_go.h
│ │ └── cursor_go_test.cc
│ ├── dark_chess
│ │ ├── dark_chess.cc
│ │ ├── dark_chess.h
│ │ └── dark_chess_test.cc
│ ├── dark_hex
│ │ ├── dark_hex.cc
│ │ ├── dark_hex.h
│ │ └── dark_hex_test.cc
│ ├── deep_sea
│ │ ├── deep_sea.cc
│ │ ├── deep_sea.h
│ │ └── deep_sea_test.cc
│ ├── dots_and_boxes
│ │ ├── dots_and_boxes.cc
│ │ ├── dots_and_boxes.h
│ │ └── dots_and_boxes_test.cc
│ ├── dou_dizhu
│ │ ├── dou_dizhu.cc
│ │ ├── dou_dizhu.h
│ │ ├── dou_dizhu_test.cc
│ │ ├── dou_dizhu_utils.cc
│ │ ├── dou_dizhu_utils.h
│ │ └── dou_dizhu_utils_test.cc
│ ├── dynamic_routing
│ │ ├── dynamic_routing_data.cc
│ │ ├── dynamic_routing_data.h
│ │ ├── dynamic_routing_data_test.cc
│ │ ├── dynamic_routing_utils.cc
│ │ ├── dynamic_routing_utils.h
│ │ └── dynamic_routing_utils_test.cc
│ ├── efg_game
│ │ ├── efg_game.cc
│ │ ├── efg_game.h
│ │ ├── efg_game_data.cc
│ │ ├── efg_game_data.h
│ │ ├── efg_game_test.cc
│ │ └── games
│ │ │ ├── README.md
│ │ │ ├── commas.efg
│ │ │ ├── extended_bos.efg
│ │ │ ├── extended_mp.efg
│ │ │ ├── extended_shapleys.efg
│ │ │ ├── greenwald_sarfati_example1.efg
│ │ │ ├── greenwald_sarfati_example2.efg
│ │ │ ├── kuhn_poker.efg
│ │ │ ├── leduc_poker.efg
│ │ │ ├── sample.efg
│ │ │ └── signaling_vonstengel_forges_2008.efg
│ ├── einstein_wurfelt_nicht
│ │ ├── einstein_wurfelt_nicht.cc
│ │ ├── einstein_wurfelt_nicht.h
│ │ └── einstein_wurfelt_nicht_test.cc
│ ├── euchre
│ │ ├── euchre.cc
│ │ ├── euchre.h
│ │ └── euchre_test.cc
│ ├── first_sealed_auction
│ │ ├── first_sealed_auction.cc
│ │ ├── first_sealed_auction.h
│ │ └── first_sealed_auction_test.cc
│ ├── gamut
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── gamut.cc
│ │ ├── gamut.h
│ │ ├── gamut_pybind11.cc
│ │ ├── gamut_pybind11.h
│ │ ├── gamut_test.cc
│ │ └── gamut_test.py
│ ├── gin_rummy
│ │ ├── gin_rummy.cc
│ │ ├── gin_rummy.h
│ │ ├── gin_rummy_test.cc
│ │ ├── gin_rummy_utils.cc
│ │ └── gin_rummy_utils.h
│ ├── go
│ │ ├── go.cc
│ │ ├── go.h
│ │ ├── go_board.cc
│ │ ├── go_board.h
│ │ └── go_test.cc
│ ├── goofspiel
│ │ ├── goofspiel.cc
│ │ ├── goofspiel.h
│ │ └── goofspiel_test.cc
│ ├── hanabi
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── hanabi.cc
│ │ ├── hanabi.h
│ │ └── hanabi_test.cc
│ ├── havannah
│ │ ├── havannah.cc
│ │ ├── havannah.h
│ │ └── havannah_test.cc
│ ├── hearts
│ │ ├── hearts.cc
│ │ ├── hearts.h
│ │ └── hearts_test.cc
│ ├── hex
│ │ ├── hex.cc
│ │ ├── hex.h
│ │ └── hex_test.cc
│ ├── hive
│ │ ├── README.md
│ │ ├── hive.cc
│ │ ├── hive.h
│ │ ├── hive_board.cc
│ │ ├── hive_board.h
│ │ └── hive_test.cc
│ ├── kriegspiel
│ │ ├── kriegspiel.cc
│ │ ├── kriegspiel.h
│ │ └── kriegspiel_test.cc
│ ├── kuhn_poker
│ │ ├── kuhn_poker.cc
│ │ ├── kuhn_poker.h
│ │ └── kuhn_poker_test.cc
│ ├── laser_tag
│ │ ├── laser_tag.cc
│ │ ├── laser_tag.h
│ │ └── laser_tag_test.cc
│ ├── leduc_poker
│ │ ├── leduc_poker.cc
│ │ ├── leduc_poker.h
│ │ └── leduc_poker_test.cc
│ ├── lewis_signaling
│ │ ├── lewis_signaling.cc
│ │ ├── lewis_signaling.h
│ │ └── lewis_signaling_test.cc
│ ├── liars_dice
│ │ ├── liars_dice.cc
│ │ ├── liars_dice.h
│ │ └── liars_dice_test.cc
│ ├── maedn
│ │ ├── maedn.cc
│ │ ├── maedn.h
│ │ └── maedn_test.cc
│ ├── mancala
│ │ ├── mancala.cc
│ │ ├── mancala.h
│ │ └── mancala_test.cc
│ ├── markov_soccer
│ │ ├── markov_soccer.cc
│ │ ├── markov_soccer.h
│ │ └── markov_soccer_test.cc
│ ├── matching_pennies_3p
│ │ ├── matching_pennies_3p.cc
│ │ ├── matching_pennies_3p.h
│ │ └── matching_pennies_3p_test.cc
│ ├── matrix_games
│ │ ├── matrix_games.cc
│ │ └── matrix_games_test.cc
│ ├── mfg
│ │ ├── README.md
│ │ ├── crowd_modelling.cc
│ │ ├── crowd_modelling.h
│ │ ├── crowd_modelling_2d.cc
│ │ ├── crowd_modelling_2d.h
│ │ ├── crowd_modelling_2d_test.cc
│ │ ├── crowd_modelling_test.cc
│ │ ├── dynamic_routing.cc
│ │ ├── dynamic_routing.h
│ │ ├── dynamic_routing_test.cc
│ │ ├── garnet.cc
│ │ ├── garnet.h
│ │ └── garnet_test.cc
│ ├── mnk
│ │ ├── mnk.cc
│ │ ├── mnk.h
│ │ └── mnk_test.cc
│ ├── morpion_solitaire
│ │ ├── morpion_solitaire.cc
│ │ ├── morpion_solitaire.h
│ │ └── morpion_solitaire_test.cc
│ ├── negotiation
│ │ ├── negotiation.cc
│ │ ├── negotiation.h
│ │ └── negotiation_test.cc
│ ├── nfg_game
│ │ ├── games
│ │ │ ├── matching_pennies_3p.nfg
│ │ │ └── sample.nfg
│ │ ├── nfg_game.cc
│ │ ├── nfg_game.h
│ │ └── nfg_game_test.cc
│ ├── nim
│ │ ├── nim.cc
│ │ ├── nim.h
│ │ └── nim_test.cc
│ ├── nine_mens_morris
│ │ ├── nine_mens_morris.cc
│ │ ├── nine_mens_morris.h
│ │ └── nine_mens_morris_test.cc
│ ├── oh_hell
│ │ ├── oh_hell.cc
│ │ ├── oh_hell.h
│ │ └── oh_hell_test.cc
│ ├── oshi_zumo
│ │ ├── oshi_zumo.cc
│ │ ├── oshi_zumo.h
│ │ └── oshi_zumo_test.cc
│ ├── othello
│ │ ├── othello.cc
│ │ ├── othello.h
│ │ └── othello_test.cc
│ ├── oware
│ │ ├── oware.cc
│ │ ├── oware.h
│ │ ├── oware_board.cc
│ │ ├── oware_board.h
│ │ └── oware_test.cc
│ ├── pathfinding
│ │ ├── pathfinding.cc
│ │ ├── pathfinding.h
│ │ └── pathfinding_test.cc
│ ├── pentago
│ │ ├── pentago.cc
│ │ ├── pentago.h
│ │ └── pentago_test.cc
│ ├── phantom_go
│ │ ├── phantom_go.cc
│ │ ├── phantom_go.h
│ │ ├── phantom_go_board.cc
│ │ ├── phantom_go_board.h
│ │ └── phantom_go_test.cc
│ ├── phantom_ttt
│ │ ├── phantom_ttt.cc
│ │ ├── phantom_ttt.h
│ │ └── phantom_ttt_test.cc
│ ├── pig
│ │ ├── pig.cc
│ │ ├── pig.h
│ │ └── pig_test.cc
│ ├── quoridor
│ │ ├── quoridor.cc
│ │ ├── quoridor.h
│ │ └── quoridor_test.cc
│ ├── rbc
│ │ ├── rbc.cc
│ │ ├── rbc.h
│ │ └── rbc_test.cc
│ ├── sheriff
│ │ ├── sheriff.cc
│ │ ├── sheriff.h
│ │ └── sheriff_test.cc
│ ├── skat
│ │ ├── skat.cc
│ │ ├── skat.h
│ │ └── skat_test.cc
│ ├── solitaire
│ │ ├── solitaire.cc
│ │ ├── solitaire.h
│ │ └── solitaire_test.cc
│ ├── spades
│ │ ├── spades.cc
│ │ ├── spades.h
│ │ ├── spades_scoring.cc
│ │ ├── spades_scoring.h
│ │ └── spades_test.cc
│ ├── stones_and_gems
│ │ ├── stones_and_gems.cc
│ │ ├── stones_and_gems.h
│ │ └── stones_and_gems_test.cc
│ ├── tarok
│ │ ├── README.md
│ │ ├── cards.cc
│ │ ├── cards.h
│ │ ├── contracts.cc
│ │ ├── contracts.h
│ │ ├── tarok.cc
│ │ ├── tarok.h
│ │ └── tarok_test.cc
│ ├── tic_tac_toe
│ │ ├── tic_tac_toe.cc
│ │ ├── tic_tac_toe.h
│ │ └── tic_tac_toe_test.cc
│ ├── tiny_bridge
│ │ ├── tiny_bridge.cc
│ │ ├── tiny_bridge.h
│ │ └── tiny_bridge_test.cc
│ ├── tiny_hanabi
│ │ ├── tiny_hanabi.cc
│ │ ├── tiny_hanabi.h
│ │ └── tiny_hanabi_test.cc
│ ├── trade_comm
│ │ ├── trade_comm.cc
│ │ ├── trade_comm.h
│ │ └── trade_comm_test.cc
│ ├── twenty_forty_eight
│ │ ├── 2048.cc
│ │ ├── 2048.h
│ │ └── 2048_test.cc
│ ├── twixt
│ │ ├── twixt.cc
│ │ ├── twixt.h
│ │ ├── twixt_test.cc
│ │ ├── twixtboard.cc
│ │ ├── twixtboard.h
│ │ └── twixtcell.h
│ ├── ultimate_tic_tac_toe
│ │ ├── ultimate_tic_tac_toe.cc
│ │ ├── ultimate_tic_tac_toe.h
│ │ └── ultimate_tic_tac_toe_test.cc
│ ├── universal_poker
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── acpc_cpp
│ │ │ ├── acpc_game.cc
│ │ │ ├── acpc_game.h
│ │ │ └── acpc_game_test.cc
│ │ ├── endgames
│ │ │ ├── subgame1.txt
│ │ │ ├── subgame2.txt
│ │ │ ├── subgame3.txt
│ │ │ └── subgame4.txt
│ │ ├── logic
│ │ │ ├── action_translation.cc
│ │ │ ├── action_translation.h
│ │ │ ├── action_translation_test.cc
│ │ │ ├── card_set.cc
│ │ │ ├── card_set.h
│ │ │ ├── card_set_test.cc
│ │ │ ├── gamedef.cc
│ │ │ ├── gamedef.h
│ │ │ └── gamedef_test.cc
│ │ ├── universal_poker.cc
│ │ ├── universal_poker.h
│ │ └── universal_poker_test.cc
│ └── y
│ │ ├── y.cc
│ │ ├── y.h
│ │ └── y_test.cc
├── go
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── example_leduc_test.go
│ ├── example_test.go
│ ├── examples
│ │ └── example.go
│ ├── go_open_spiel.cc
│ ├── go_open_spiel.h
│ └── openspiel.go
├── integration_tests
│ ├── README.md
│ ├── __init__.py
│ ├── api_test.py
│ ├── example_connect_four_state.txt
│ ├── playthrough_test.py
│ └── playthroughs
│ │ ├── 2048.txt
│ │ ├── add_noise(epsilon=1.,seed=1,game=kuhn_poker()).txt
│ │ ├── amazons.txt
│ │ ├── backgammon(hyper_backgammon=true).txt
│ │ ├── backgammon.txt
│ │ ├── bargaining.txt
│ │ ├── battleship.txt
│ │ ├── blackjack.txt
│ │ ├── blotto.txt
│ │ ├── breakthrough.txt
│ │ ├── bridge(use_double_dummy_result=false).txt
│ │ ├── bridge.txt
│ │ ├── bridge_uncontested_bidding-2NT.txt
│ │ ├── bridge_uncontested_bidding.txt
│ │ ├── cached_tree(game=tic_tac_toe()).txt
│ │ ├── catch.txt
│ │ ├── chat_game.txt
│ │ ├── checkers.txt
│ │ ├── chess.txt
│ │ ├── cliff_walking.txt
│ │ ├── clobber.txt
│ │ ├── coin_game.txt
│ │ ├── colored_trails.txt
│ │ ├── connect_four.txt
│ │ ├── connect_four_start_at.txt
│ │ ├── coop_box_pushing.txt
│ │ ├── coop_to_1p(game=tiny_bridge_2p()).txt
│ │ ├── coop_to_1p(game=tiny_hanabi()).txt
│ │ ├── coordinated_mp.txt
│ │ ├── crazy_eights.txt
│ │ ├── cribbage.txt
│ │ ├── cursor_go(board_size=5,max_cursor_moves=7).txt
│ │ ├── dark_chess(board_size=4).txt
│ │ ├── dark_chess.txt
│ │ ├── dark_hex(num_rows=5,num_cols=3).txt
│ │ ├── dark_hex_ir(board_size=3).txt
│ │ ├── dark_hex_reveal_turn_long.txt
│ │ ├── deep_sea.txt
│ │ ├── dots_and_boxes.txt
│ │ ├── dou_dizhu.txt
│ │ ├── einstein_wurfelt_nicht.txt
│ │ ├── euchre.txt
│ │ ├── first_sealed_auction.txt
│ │ ├── gin_rummy.txt
│ │ ├── go.txt
│ │ ├── goofspiel.txt
│ │ ├── goofspiel_egocentric.txt
│ │ ├── goofspiel_random_points_order.txt
│ │ ├── goofspiel_turn_based.txt
│ │ ├── hanabi.txt
│ │ ├── havannah(board_size=4).txt
│ │ ├── havannah(board_size=4,swap=True).txt
│ │ ├── hearts.txt
│ │ ├── hex(board_size=5).txt
│ │ ├── hive.txt
│ │ ├── kriegspiel(board_size=4).txt
│ │ ├── kuhn_poker_2p.txt
│ │ ├── kuhn_poker_3p.txt
│ │ ├── laser_tag(fully_obs=false,horizon=20).txt
│ │ ├── laser_tag(horizon=20).txt
│ │ ├── leduc_poker_1540482260.txt
│ │ ├── leduc_poker_3977671846.txt
│ │ ├── leduc_poker_3p.txt
│ │ ├── leduc_poker_3p_single_tensor.txt
│ │ ├── leduc_poker_773740114.txt
│ │ ├── lewis_signaling.txt
│ │ ├── liars_dice.txt
│ │ ├── liars_dice_ir.txt
│ │ ├── maedn.txt
│ │ ├── mancala.txt
│ │ ├── markov_soccer.txt
│ │ ├── matching_pennies_3p.txt
│ │ ├── matrix_bos.txt
│ │ ├── matrix_brps.txt
│ │ ├── matrix_cd.txt
│ │ ├── matrix_coordination.txt
│ │ ├── matrix_mp.txt
│ │ ├── matrix_pd.txt
│ │ ├── matrix_rps.txt
│ │ ├── matrix_rpsw.txt
│ │ ├── matrix_sh.txt
│ │ ├── matrix_shapleys_game.txt
│ │ ├── mean_field_lin_quad.txt
│ │ ├── mfg_crowd_modelling.txt
│ │ ├── mfg_crowd_modelling_2d.txt
│ │ ├── mfg_dynamic_routing.txt
│ │ ├── mfg_garnet.txt
│ │ ├── misere(game=kuhn_poker()).txt
│ │ ├── misere(game=pig(players=3,horizon=20,winscore=6)).txt
│ │ ├── misere(game=tic_tac_toe()).txt
│ │ ├── mnk.txt
│ │ ├── morpion_solitaire.txt
│ │ ├── negotiation(rng_seed=100,utterance_dim=2,num_symbols=3).txt
│ │ ├── nim.txt
│ │ ├── nine_mens_morris.txt
│ │ ├── normal_form_extensive_game(game=first_sealed_auction(players=3,max_value=3)).txt
│ │ ├── oh_hell.txt
│ │ ├── oshi_zumo.txt
│ │ ├── othello.txt
│ │ ├── oware.txt
│ │ ├── pathfinding.txt
│ │ ├── pentago.txt
│ │ ├── phantom_go.txt
│ │ ├── phantom_ttt.txt
│ │ ├── phantom_ttt_ir.txt
│ │ ├── pig_3p.txt
│ │ ├── pig_4p.txt
│ │ ├── pig_5p.txt
│ │ ├── python_block_dominoes.txt
│ │ ├── python_dynamic_routing.txt
│ │ ├── python_iterated_prisoners_dilemma.txt
│ │ ├── python_iterated_prisoners_dilemma_turn_based.txt
│ │ ├── python_kuhn_poker.txt
│ │ ├── python_liars_poker.txt
│ │ ├── python_mfg_crowd_avoidance.txt
│ │ ├── python_mfg_crowd_modelling.txt
│ │ ├── python_mfg_dynamic_routing.txt
│ │ ├── python_mfg_periodic_aversion.txt
│ │ ├── python_mfg_predator_prey.txt
│ │ ├── python_team_dominoes.txt
│ │ ├── python_tic_tac_toe.txt
│ │ ├── quoridor(board_size=5).txt
│ │ ├── quoridor(players=4).txt
│ │ ├── rbc(board_size=4).txt
│ │ ├── rbc.txt
│ │ ├── repeated_game(stage_game=matrix_rps(),num_repetitions=10).txt
│ │ ├── sheriff.txt
│ │ ├── skat.txt
│ │ ├── solitaire.txt
│ │ ├── spades.txt
│ │ ├── stones_and_gems.txt
│ │ ├── tarok(players=3,rng_seed=0).txt
│ │ ├── tarok(players=4,rng_seed=0).txt
│ │ ├── tic_tac_toe.txt
│ │ ├── tiny_bridge_2p(abstracted=true).txt
│ │ ├── tiny_bridge_2p.txt
│ │ ├── tiny_bridge_4p.txt
│ │ ├── tiny_hanabi(2p2a2c_hard5)
│ │ ├── tiny_hanabi.txt
│ │ ├── trade_comm.txt
│ │ ├── twixt.txt
│ │ ├── ultimate_tic_tac_toe.txt
│ │ ├── universal_poker(bettingAbstraction=fullgame).txt
│ │ ├── universal_poker.txt
│ │ ├── y(board_size=9).txt
│ │ └── zerosum(game=oh_hell()).txt
├── julia
│ ├── CMakeLists.txt
│ ├── Project.toml
│ ├── README.md
│ ├── deps
│ │ └── deps.jl
│ ├── src
│ │ ├── OpenSpiel.jl
│ │ └── patch.jl
│ ├── test
│ │ ├── bots.jl
│ │ ├── cfr.jl
│ │ ├── games_api.jl
│ │ ├── games_simulation.jl
│ │ ├── runtests.jl
│ │ └── trajector.jl
│ └── wrapper
│ │ └── spieljl.cc
├── libnop
│ ├── CMakeLists.txt
│ └── libnop_integration_test.cc
├── libtorch
│ ├── .gitignore
│ ├── CMakeLists.txt
│ └── torch_integration_test.cc
├── matrix_game.cc
├── matrix_game.h
├── normal_form_game.h
├── observer.cc
├── observer.h
├── policy.cc
├── policy.h
├── python
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── __init__.py
│ ├── algorithms
│ │ ├── __init__.py
│ │ ├── action_value.py
│ │ ├── action_value_test.py
│ │ ├── action_value_vs_best_response.py
│ │ ├── action_value_vs_best_response_test.py
│ │ ├── adidas.py
│ │ ├── adidas_test.py
│ │ ├── adidas_utils
│ │ │ ├── __init__.py
│ │ │ ├── games
│ │ │ │ ├── __init__.py
│ │ │ │ ├── big.py
│ │ │ │ ├── gamut.py
│ │ │ │ ├── pyspiel_tensor_game.py
│ │ │ │ ├── small.py
│ │ │ │ └── small_test.py
│ │ │ ├── helpers
│ │ │ │ ├── __init__.py
│ │ │ │ ├── misc.py
│ │ │ │ ├── nonsymmetric
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── exploitability.py
│ │ │ │ │ ├── exploitability_test.py
│ │ │ │ │ ├── game_runner.py
│ │ │ │ │ └── updates.py
│ │ │ │ ├── simplex.py
│ │ │ │ ├── simplex_test.py
│ │ │ │ └── symmetric
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── exploitability.py
│ │ │ │ │ ├── exploitability_test.py
│ │ │ │ │ ├── game_runner.py
│ │ │ │ │ ├── updates.py
│ │ │ │ │ ├── utils.py
│ │ │ │ │ └── utils_test.py
│ │ │ └── solvers
│ │ │ │ ├── __init__.py
│ │ │ │ ├── nonsymmetric
│ │ │ │ ├── __init__.py
│ │ │ │ ├── adam.py
│ │ │ │ ├── adam_anneal.py
│ │ │ │ ├── ate.py
│ │ │ │ ├── ate_anneal.py
│ │ │ │ ├── ate_poly.py
│ │ │ │ ├── ate_regmatch.py
│ │ │ │ ├── ped.py
│ │ │ │ ├── pg.py
│ │ │ │ ├── qre.py
│ │ │ │ ├── qre_anneal.py
│ │ │ │ ├── regmatch.py
│ │ │ │ ├── sgd.py
│ │ │ │ └── solvers_test.py
│ │ │ │ └── symmetric
│ │ │ │ ├── __init__.py
│ │ │ │ ├── adam.py
│ │ │ │ ├── adam_anneal.py
│ │ │ │ ├── ate.py
│ │ │ │ ├── ate_anneal.py
│ │ │ │ ├── ped.py
│ │ │ │ ├── pg.py
│ │ │ │ ├── qre.py
│ │ │ │ ├── qre_anneal.py
│ │ │ │ ├── qre_anneal_noaux.py
│ │ │ │ ├── regmatch.py
│ │ │ │ ├── sgd.py
│ │ │ │ └── solvers_test.py
│ │ ├── alpha_zero
│ │ │ ├── README.md
│ │ │ ├── __init__.py
│ │ │ ├── alpha_zero.py
│ │ │ ├── analysis.py
│ │ │ ├── evaluator.py
│ │ │ ├── evaluator_test.py
│ │ │ ├── export_model.py
│ │ │ ├── model.py
│ │ │ └── model_test.py
│ │ ├── async_mcts.py
│ │ ├── async_mcts_test.py
│ │ ├── best_response.py
│ │ ├── best_response_test.py
│ │ ├── boltzmann_tabular_qlearner.py
│ │ ├── boltzmann_tabular_qlearner_test.py
│ │ ├── cfr.py
│ │ ├── cfr_br.py
│ │ ├── cfr_br_test.py
│ │ ├── cfr_test.py
│ │ ├── discounted_cfr.py
│ │ ├── discounted_cfr_test.py
│ │ ├── double_oracle.py
│ │ ├── double_oracle_test.py
│ │ ├── efr.py
│ │ ├── efr_test.py
│ │ ├── evaluate_bots.py
│ │ ├── evaluate_bots_test.py
│ │ ├── expected_game_score.py
│ │ ├── expected_game_score_test.py
│ │ ├── exploitability.py
│ │ ├── exploitability_test.py
│ │ ├── external_sampling_mccfr.py
│ │ ├── external_sampling_mccfr_test.py
│ │ ├── fictitious_play.py
│ │ ├── fictitious_play_test.py
│ │ ├── gambit.py
│ │ ├── gambit_test.py
│ │ ├── generate_playthrough.py
│ │ ├── generate_playthrough_test.py
│ │ ├── get_all_states.py
│ │ ├── get_all_states_test.py
│ │ ├── ismcts.py
│ │ ├── ismcts_agent_test.py
│ │ ├── ismcts_test.py
│ │ ├── jpsro.py
│ │ ├── jpsro_test.py
│ │ ├── lp_solver.py
│ │ ├── lp_solver_test.py
│ │ ├── matrix_nash.py
│ │ ├── mccfr.py
│ │ ├── mcts.py
│ │ ├── mcts_agent.py
│ │ ├── mcts_agent_test.py
│ │ ├── mcts_test.py
│ │ ├── minimax.py
│ │ ├── minimax_test.py
│ │ ├── mip_nash.py
│ │ ├── mip_nash_test.py
│ │ ├── mmd_dilated.py
│ │ ├── mmd_dilated_test.py
│ │ ├── nash_averaging.py
│ │ ├── nash_averaging_test.py
│ │ ├── nfg_utils.py
│ │ ├── nfg_utils_test.py
│ │ ├── noisy_policy.py
│ │ ├── noisy_policy_test.py
│ │ ├── outcome_sampling_mccfr.py
│ │ ├── outcome_sampling_mccfr_test.py
│ │ ├── policy_aggregator.py
│ │ ├── policy_aggregator_joint.py
│ │ ├── policy_aggregator_joint_test.py
│ │ ├── policy_aggregator_test.py
│ │ ├── policy_utils.py
│ │ ├── projected_replicator_dynamics.py
│ │ ├── projected_replicator_dynamics_test.py
│ │ ├── psro_v2
│ │ │ ├── __init__.py
│ │ │ ├── abstract_meta_trainer.py
│ │ │ ├── best_response_oracle.py
│ │ │ ├── best_response_oracle_test.py
│ │ │ ├── meta_strategies.py
│ │ │ ├── optimization_oracle.py
│ │ │ ├── psro_v2.py
│ │ │ ├── rl_oracle.py
│ │ │ ├── rl_policy.py
│ │ │ ├── strategy_selectors.py
│ │ │ ├── strategy_selectors_test.py
│ │ │ └── utils.py
│ │ ├── random_agent.py
│ │ ├── random_agent_test.py
│ │ ├── regret_matching.py
│ │ ├── regret_matching_test.py
│ │ ├── response_graph_ucb.py
│ │ ├── response_graph_ucb_test.py
│ │ ├── response_graph_ucb_utils.py
│ │ ├── sample_some_states.py
│ │ ├── sample_some_states_test.py
│ │ ├── sequence_form_lp.py
│ │ ├── sequence_form_lp_test.py
│ │ ├── sequence_form_utils.py
│ │ ├── sequence_form_utils_test.py
│ │ ├── stackelberg_lp.py
│ │ ├── stackelberg_lp_test.py
│ │ ├── tabular_multiagent_qlearner.py
│ │ ├── tabular_multiagent_qlearner_test.py
│ │ ├── tabular_qlearner.py
│ │ ├── tabular_qlearner_test.py
│ │ ├── tf
│ │ │ ├── README.md
│ │ │ ├── alpha_zero_example.py
│ │ │ ├── deep_cfr.py
│ │ │ ├── deep_cfr_example.py
│ │ │ ├── deep_cfr_test.py
│ │ │ ├── deep_cfr_tf2.py
│ │ │ ├── deep_cfr_tf2_test.py
│ │ │ ├── dqn.py
│ │ │ ├── dqn_test.py
│ │ │ ├── eva.py
│ │ │ ├── eva_test.py
│ │ │ ├── exploitability_descent.py
│ │ │ ├── exploitability_descent_test.py
│ │ │ ├── kuhn_policy_gradient_example.py
│ │ │ ├── leduc_nfsp_example.py
│ │ │ ├── lewis_signaling_dqn_example.py
│ │ │ ├── masked_softmax.py
│ │ │ ├── masked_softmax_test.py
│ │ │ ├── neurd.py
│ │ │ ├── neurd_example.py
│ │ │ ├── neurd_test.py
│ │ │ ├── nfsp.py
│ │ │ ├── nfsp_test.py
│ │ │ ├── policy_gradient.py
│ │ │ ├── policy_gradient_test.py
│ │ │ ├── rcfr.py
│ │ │ ├── rcfr_example.py
│ │ │ ├── rcfr_test.py
│ │ │ ├── rl_losses.py
│ │ │ ├── rl_losses_test.py
│ │ │ ├── single_agent_catch_example.py
│ │ │ ├── skat_dqn_example.py
│ │ │ └── tic_tac_toe_alpha_zero_example.py
│ │ ├── value_iteration.py
│ │ ├── value_iteration_test.py
│ │ ├── wolf_phc.py
│ │ └── wolf_phc_test.py
│ ├── bots
│ │ ├── __init__.py
│ │ ├── bluechip_bridge.py
│ │ ├── bluechip_bridge_test.py
│ │ ├── bluechip_bridge_uncontested_bidding.py
│ │ ├── bluechip_bridge_uncontested_bidding_test.py
│ │ ├── gtp.py
│ │ ├── human.py
│ │ ├── is_mcts_test.py
│ │ ├── policy.py
│ │ ├── scenarios.py
│ │ ├── uniform_random.py
│ │ └── uniform_random_test.py
│ ├── coalitional_games
│ │ ├── __init__.py
│ │ ├── basic_games.py
│ │ ├── coalitional_game.py
│ │ ├── deon_larson20_games.py
│ │ ├── least_core_lagrangian.py
│ │ ├── least_core_lagrangian_test.py
│ │ ├── least_core_lp.py
│ │ ├── least_core_lp_test.py
│ │ ├── shapley_values.py
│ │ ├── shapley_values_test.py
│ │ ├── util.py
│ │ ├── wvg.py
│ │ └── wvg_test.py
│ ├── egt
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── alpharank.py
│ │ ├── alpharank_test.py
│ │ ├── alpharank_visualizer.py
│ │ ├── alpharank_visualizer_test.py
│ │ ├── dynamics.py
│ │ ├── dynamics_test.py
│ │ ├── examples
│ │ │ ├── __init__.py
│ │ │ └── alpharank_example.py
│ │ ├── heuristic_payoff_table.py
│ │ ├── heuristic_payoff_table_test.py
│ │ ├── utils.py
│ │ ├── utils_test.py
│ │ ├── visualization.py
│ │ └── visualization_test.py
│ ├── environments
│ │ ├── __init__.py
│ │ ├── catch.py
│ │ ├── catch_test.py
│ │ ├── cliff_walking.py
│ │ ├── cliff_walking_test.py
│ │ └── iterated_matrix_game.py
│ ├── examples
│ │ ├── __init__.py
│ │ ├── benchmark_games.py
│ │ ├── breakthrough_dqn.py
│ │ ├── bridge_supervised_learning.py
│ │ ├── bridge_uncontested_bidding_bluechip.py
│ │ ├── bridge_wb5.py
│ │ ├── catch_jax_policy_gradient.py
│ │ ├── catch_pytorch_policy_gradient.py
│ │ ├── cfr_cpp_example.py
│ │ ├── cfr_example.py
│ │ ├── chat_game_cfr_example.py
│ │ ├── chat_game_psro_example.py
│ │ ├── data
│ │ │ ├── bridge
│ │ │ │ ├── test.txt
│ │ │ │ └── train.txt
│ │ │ └── hearts
│ │ │ │ ├── test.txt
│ │ │ │ └── train.txt
│ │ ├── deep_cfr_jax.py
│ │ ├── deep_cfr_pytorch.py
│ │ ├── deep_cfr_tf2.py
│ │ ├── discounted_cfr.py
│ │ ├── dots_and_boxes_example.py
│ │ ├── eva.py
│ │ ├── example.py
│ │ ├── exploitability_descent.py
│ │ ├── fictitious_play_example.py
│ │ ├── gambit_example.py
│ │ ├── game_tree_traversal_example.py
│ │ ├── get_all_states.py
│ │ ├── hearts_supervised_learning.py
│ │ ├── independent_tabular_qlearning.py
│ │ ├── is_mcts_exploitability.py
│ │ ├── jpsro.py
│ │ ├── kuhn_poker_cfr.py
│ │ ├── lewis_signaling_qlearner.py
│ │ ├── lp_solve_example.py
│ │ ├── marl_nashq_example.py
│ │ ├── matrix_game_example.py
│ │ ├── matrix_nash_example.py
│ │ ├── mccfr_cpp_example.py
│ │ ├── mccfr_example.py
│ │ ├── mcts.py
│ │ ├── meta_cfr
│ │ │ ├── matrix_games
│ │ │ │ ├── evaluation.py
│ │ │ │ ├── main.py
│ │ │ │ ├── matrix_dataset.py
│ │ │ │ ├── meta_selfplay_agent.py
│ │ │ │ ├── regret_matching_agent.py
│ │ │ │ ├── rnn_meta_selfplay_agent.py
│ │ │ │ ├── rnn_model.py
│ │ │ │ └── utils.py
│ │ │ └── sequential_games
│ │ │ │ ├── cfr.py
│ │ │ │ ├── cfr_test.py
│ │ │ │ ├── dataset_generator.py
│ │ │ │ ├── evaluation.py
│ │ │ │ ├── game_tree_utils.py
│ │ │ │ ├── main.py
│ │ │ │ ├── meta_learning.py
│ │ │ │ ├── meta_learning_test.py
│ │ │ │ ├── models.py
│ │ │ │ ├── openspiel_api.py
│ │ │ │ ├── typing.py
│ │ │ │ ├── utils.py
│ │ │ │ └── world_representation.py
│ │ ├── mmd_example.py
│ │ ├── mmd_matrix_example.py
│ │ ├── mmd_nash_example.py
│ │ ├── nego_nbs_example.py
│ │ ├── nfg_writer_example.py
│ │ ├── nfsp.py
│ │ ├── opponent_shaping
│ │ │ ├── lola_iterated_matrix_games_jax.py
│ │ │ └── requirements.txt
│ │ ├── play_scenarios.py
│ │ ├── play_tarok_game.py
│ │ ├── play_via_console_example.py
│ │ ├── playthrough.py
│ │ ├── poker_fcpa_example.py
│ │ ├── policy_aggregator_example.py
│ │ ├── ppo_example.py
│ │ ├── psro_v2_example.py
│ │ ├── query_example.py
│ │ ├── response_graph_ucb_2x2_game.py
│ │ ├── response_graph_ucb_sample_complexity.py
│ │ ├── rl_example.py
│ │ ├── rl_main_loop.py
│ │ ├── rl_response.py
│ │ ├── roshambo_population_example.py
│ │ ├── rrps_poprl
│ │ │ ├── README.md
│ │ │ ├── impala.py
│ │ │ ├── impala_jax_test.py
│ │ │ ├── poprl_main.py
│ │ │ └── rl_environment.py
│ │ ├── single_agent_cliff_walking.py
│ │ ├── tic_tac_toe_dqn_vs_tabular.py
│ │ ├── tic_tac_toe_qlearner.py
│ │ ├── treeviz_example.py
│ │ ├── twenty_forty_eight_td_n_tuple_network.py
│ │ ├── uniform_policy_exploitability.py
│ │ ├── universal_poker_cfr_cpp_load_from_acpc_gamedef_example.py
│ │ └── value_iteration.py
│ ├── games
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── atari.py
│ │ ├── block_dominoes.py
│ │ ├── block_dominoes_test.py
│ │ ├── chat_game.py
│ │ ├── chat_game_test.py
│ │ ├── chat_games
│ │ │ ├── __init__.py
│ │ │ ├── chat_game_base.py
│ │ │ ├── configs
│ │ │ │ ├── __init__.py
│ │ │ │ ├── config_debate.py
│ │ │ │ ├── config_debate_fixed.py
│ │ │ │ ├── config_fixed_mock.py
│ │ │ │ ├── config_rnd_mock.py
│ │ │ │ ├── config_rwneg.py
│ │ │ │ ├── config_schedule_meeting.py
│ │ │ │ ├── config_schedule_meeting_w_dow.py
│ │ │ │ ├── config_schedule_meeting_w_dow_fixed.py
│ │ │ │ ├── config_schedule_meeting_w_tone.py
│ │ │ │ ├── config_schedule_meeting_w_tone_fixed.py
│ │ │ │ ├── config_trade_fruit.py
│ │ │ │ ├── config_trade_fruit_w_tone.py
│ │ │ │ └── config_trade_fruit_w_tone_fixed.py
│ │ │ ├── envs
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_envs
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── base_envs_test.py
│ │ │ │ │ ├── debate_with_style_info.py
│ │ │ │ │ ├── email_plain.py
│ │ │ │ │ ├── email_with_tone.py
│ │ │ │ │ ├── email_with_tone_info.py
│ │ │ │ │ ├── schedule_meeting_with_dow_info.py
│ │ │ │ │ ├── schedule_meeting_with_info.py
│ │ │ │ │ ├── schedule_meeting_with_tone_info.py
│ │ │ │ │ ├── trade_fruit_with_info.py
│ │ │ │ │ └── trade_fruit_with_tone_info.py
│ │ │ │ ├── comm_substrates
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── debates.py
│ │ │ │ │ ├── emails.py
│ │ │ │ │ ├── schedules.py
│ │ │ │ │ └── trades.py
│ │ │ │ ├── observations
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── summary.py
│ │ │ │ │ ├── summary_debate.py
│ │ │ │ │ └── utils.py
│ │ │ │ ├── payoffs
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── debate.py
│ │ │ │ │ ├── schedule_meeting.py
│ │ │ │ │ ├── sentiment.py
│ │ │ │ │ ├── trade_fruit.py
│ │ │ │ │ └── utils.py
│ │ │ │ ├── scenarios
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── actions
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── arguments.py
│ │ │ │ │ │ └── tones.py
│ │ │ │ │ ├── domains
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── debate.py
│ │ │ │ │ │ ├── real_world_negotiations.py
│ │ │ │ │ │ ├── schedule_meeting.py
│ │ │ │ │ │ └── trade_fruit.py
│ │ │ │ │ └── players
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── names.py
│ │ │ │ ├── termination
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── utils.py
│ │ │ │ └── utils
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── header.py
│ │ │ │ │ └── text.py
│ │ │ └── utils
│ │ │ │ ├── __init__.py
│ │ │ │ ├── logging_utils.py
│ │ │ │ └── test_utils.py
│ │ ├── data.py
│ │ ├── data_test.py
│ │ ├── dynamic_routing.py
│ │ ├── dynamic_routing_data.py
│ │ ├── dynamic_routing_test.py
│ │ ├── dynamic_routing_to_mean_field_game.py
│ │ ├── dynamic_routing_to_mean_field_game_test.py
│ │ ├── dynamic_routing_utils.py
│ │ ├── dynamic_routing_utils_test.py
│ │ ├── iterated_prisoners_dilemma.py
│ │ ├── iterated_prisoners_dilemma_test.py
│ │ ├── kuhn_poker.py
│ │ ├── kuhn_poker_test.py
│ │ ├── liars_poker.py
│ │ ├── liars_poker_test.py
│ │ ├── team_dominoes.py
│ │ ├── team_dominoes_test.py
│ │ ├── tic_tac_toe.py
│ │ └── tic_tac_toe_test.py
│ ├── jax
│ │ ├── __init__.py
│ │ ├── boltzmann_dqn.py
│ │ ├── boltzmann_dqn_jax_test.py
│ │ ├── cfr
│ │ │ ├── __init__.py
│ │ │ ├── compare_cfr_with_jax.py
│ │ │ ├── jax_cfr.py
│ │ │ └── jax_cfr_test.py
│ │ ├── deep_cfr.py
│ │ ├── deep_cfr_jax_test.py
│ │ ├── dqn.py
│ │ ├── dqn_jax_test.py
│ │ ├── nfsp.py
│ │ ├── nfsp_jax_test.py
│ │ ├── opponent_shaping.py
│ │ ├── opponent_shaping_jax_test.py
│ │ ├── policy_gradient.py
│ │ └── policy_gradient_jax_test.py
│ ├── mfg
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── algorithms
│ │ │ ├── __init__.py
│ │ │ ├── average_network_fictitious_play.py
│ │ │ ├── average_network_fictitious_play_test.py
│ │ │ ├── bandit_regret.py
│ │ │ ├── benchmark.py
│ │ │ ├── best_response_value.py
│ │ │ ├── best_response_value_test.py
│ │ │ ├── boltzmann_policy_iteration.py
│ │ │ ├── boltzmann_policy_iteration_test.py
│ │ │ ├── correlated_equilibrium.py
│ │ │ ├── distribution.py
│ │ │ ├── distribution_test.py
│ │ │ ├── fictitious_play.py
│ │ │ ├── fictitious_play_test.py
│ │ │ ├── fixed_point.py
│ │ │ ├── fixed_point_test.py
│ │ │ ├── greedy_policy.py
│ │ │ ├── greedy_policy_test.py
│ │ │ ├── joint_best_response_value.py
│ │ │ ├── mf_psro.py
│ │ │ ├── mirror_descent.py
│ │ │ ├── mirror_descent_test.py
│ │ │ ├── munchausen_deep_mirror_descent.py
│ │ │ ├── munchausen_deep_mirror_descent_test.py
│ │ │ ├── munchausen_mirror_descent.py
│ │ │ ├── munchausen_mirror_descent_test.py
│ │ │ ├── nash_conv.py
│ │ │ ├── nash_conv_test.py
│ │ │ ├── policy_value.py
│ │ │ ├── policy_value_test.py
│ │ │ ├── pytorch
│ │ │ │ ├── __init__.py
│ │ │ │ ├── mfg_proximal_policy_optimization.py
│ │ │ │ └── mfg_proximal_policy_optimization_pytorch_test.py
│ │ │ ├── regret
│ │ │ │ ├── c_ce_optimization.py
│ │ │ │ ├── hedge.py
│ │ │ │ ├── nash_evolutionary_search.py
│ │ │ │ ├── nash_random_search.py
│ │ │ │ ├── polynomial_weights.py
│ │ │ │ ├── regret_matching.py
│ │ │ │ └── regret_minimizer.py
│ │ │ ├── softmax_policy.py
│ │ │ ├── softmax_policy_test.py
│ │ │ └── utils.py
│ │ ├── distribution.py
│ │ ├── examples
│ │ │ ├── mfg_average_network_fp_jax.py
│ │ │ ├── mfg_dqn_fp_jax.py
│ │ │ ├── mfg_dqn_jax.py
│ │ │ ├── mfg_fictitious_play.py
│ │ │ ├── mfg_mirror_descent.py
│ │ │ ├── mfg_munchausen_domd_jax.py
│ │ │ ├── mfg_proximal_policy_optimization_pytorch.py
│ │ │ └── mfg_psro.py
│ │ ├── games
│ │ │ ├── __init__.py
│ │ │ ├── crowd_avoidance.py
│ │ │ ├── crowd_avoidance_test.py
│ │ │ ├── crowd_modelling.py
│ │ │ ├── crowd_modelling_2d.py
│ │ │ ├── crowd_modelling_2d_test.py
│ │ │ ├── crowd_modelling_test.py
│ │ │ ├── dynamic_routing.py
│ │ │ ├── dynamic_routing_test.py
│ │ │ ├── factory.py
│ │ │ ├── factory_test.py
│ │ │ ├── linear_quadratic.py
│ │ │ ├── linear_quadratic_example.py
│ │ │ ├── linear_quadratic_test.py
│ │ │ ├── normal_form_game.py
│ │ │ ├── normal_form_game_test.py
│ │ │ ├── periodic_aversion.py
│ │ │ ├── periodic_aversion_test.py
│ │ │ ├── predator_prey.py
│ │ │ └── predator_prey_test.py
│ │ ├── tabular_distribution.py
│ │ ├── utils.py
│ │ └── value.py
│ ├── observation.py
│ ├── policy.py
│ ├── pybind11
│ │ ├── algorithms_corr_dist.cc
│ │ ├── algorithms_corr_dist.h
│ │ ├── algorithms_trajectories.cc
│ │ ├── algorithms_trajectories.h
│ │ ├── bots.cc
│ │ ├── bots.h
│ │ ├── evaluation_sco.cc
│ │ ├── evaluation_sco.h
│ │ ├── game_transforms.cc
│ │ ├── game_transforms.h
│ │ ├── games_backgammon.cc
│ │ ├── games_backgammon.h
│ │ ├── games_bargaining.cc
│ │ ├── games_bargaining.h
│ │ ├── games_blackjack.cc
│ │ ├── games_blackjack.h
│ │ ├── games_bridge.cc
│ │ ├── games_bridge.h
│ │ ├── games_chess.cc
│ │ ├── games_chess.h
│ │ ├── games_colored_trails.cc
│ │ ├── games_colored_trails.h
│ │ ├── games_dots_and_boxes.cc
│ │ ├── games_dots_and_boxes.h
│ │ ├── games_euchre.cc
│ │ ├── games_euchre.h
│ │ ├── games_gin_rummy.cc
│ │ ├── games_gin_rummy.h
│ │ ├── games_kuhn_poker.cc
│ │ ├── games_kuhn_poker.h
│ │ ├── games_leduc_poker.cc
│ │ ├── games_leduc_poker.h
│ │ ├── games_negotiation.cc
│ │ ├── games_negotiation.h
│ │ ├── games_spades.cc
│ │ ├── games_spades.h
│ │ ├── games_tarok.cc
│ │ ├── games_tarok.h
│ │ ├── games_tic_tac_toe.cc
│ │ ├── games_tic_tac_toe.h
│ │ ├── games_tiny_bridge.cc
│ │ ├── games_tiny_bridge.h
│ │ ├── games_trade_comm.cc
│ │ ├── games_trade_comm.h
│ │ ├── games_universal_poker.cc
│ │ ├── games_universal_poker.h
│ │ ├── observer.cc
│ │ ├── observer.h
│ │ ├── policy.cc
│ │ ├── policy.h
│ │ ├── pybind11.h
│ │ ├── pyspiel.cc
│ │ ├── python_games.cc
│ │ ├── python_games.h
│ │ ├── python_policy.cc
│ │ ├── python_policy.h
│ │ ├── utils.cc
│ │ └── utils.h
│ ├── pytorch
│ │ ├── __init__.py
│ │ ├── deep_cfr.py
│ │ ├── deep_cfr_pytorch_test.py
│ │ ├── dqn.py
│ │ ├── dqn_pytorch_test.py
│ │ ├── eva.py
│ │ ├── eva_pytorch_test.py
│ │ ├── losses
│ │ │ ├── __init__.py
│ │ │ ├── rl_losses.py
│ │ │ └── rl_losses_pytorch_test.py
│ │ ├── neurd.py
│ │ ├── neurd_pytorch_test.py
│ │ ├── policy_gradient.py
│ │ ├── policy_gradient_pytorch_test.py
│ │ ├── ppo.py
│ │ ├── ppo_pytorch_test.py
│ │ ├── rcfr.py
│ │ └── rcfr_pytorch_test.py
│ ├── rl_agent.py
│ ├── rl_agent_policy.py
│ ├── rl_environment.py
│ ├── rl_tools.py
│ ├── simple_nets.py
│ ├── test_utils.py
│ ├── tests
│ │ ├── __init__.py
│ │ ├── bot_test.py
│ │ ├── game_transforms_test.py
│ │ ├── games_bargaining_test.py
│ │ ├── games_blackjack_test.py
│ │ ├── games_bridge_test.py
│ │ ├── games_chess_test.py
│ │ ├── games_euchre_test.py
│ │ ├── games_gin_rummy_test.py
│ │ ├── games_sim_test.py
│ │ ├── games_tic_tac_toe_test.py
│ │ ├── matrix_game_utils_test.py
│ │ ├── mfg_implementation_test
│ │ │ ├── __init__.py
│ │ │ └── mfg_test.py
│ │ ├── nfg_game_test.py
│ │ ├── nfg_writer_test.py
│ │ ├── observation_test.py
│ │ ├── policy_test.py
│ │ ├── pyspiel_test.py
│ │ ├── rl_environment_test.py
│ │ ├── sampled_stochastic_games_test.py
│ │ └── tensor_game_utils_test.py
│ ├── utils
│ │ ├── __init__.py
│ │ ├── app.py
│ │ ├── data_logger.py
│ │ ├── file_logger.py
│ │ ├── file_logger_test.py
│ │ ├── file_utils.py
│ │ ├── gfile.py
│ │ ├── lru_cache.py
│ │ ├── lru_cache_test.py
│ │ ├── metrics.py
│ │ ├── metrics_test.py
│ │ ├── replay_buffer.py
│ │ ├── replay_buffer_test.py
│ │ ├── reservoir_buffer.py
│ │ ├── shared_value.py
│ │ ├── spawn.py
│ │ ├── spawn_test.py
│ │ ├── stats.py
│ │ └── training.py
│ ├── vector_env.py
│ ├── visualizations
│ │ ├── __init__.py
│ │ └── treeviz.py
│ └── voting
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── approval.py
│ │ ├── approval_test.py
│ │ ├── base.py
│ │ ├── base_test.py
│ │ ├── borda.py
│ │ ├── borda_test.py
│ │ ├── copeland.py
│ │ ├── copeland_test.py
│ │ ├── examples
│ │ ├── __init__.py
│ │ ├── atari.py
│ │ ├── atari_agent57_table.txt
│ │ ├── atari_datasets.py
│ │ ├── atari_muesli_table11.txt
│ │ ├── atari_rainbow_table5.txt
│ │ ├── atari_rainbow_table6.txt
│ │ ├── chatbot_arena.py
│ │ └── example.py
│ │ ├── kemeny_young.py
│ │ ├── kemeny_young_test.py
│ │ ├── maximal_lotteries.py
│ │ ├── maximal_lotteries_test.py
│ │ ├── plurality.py
│ │ ├── plurality_test.py
│ │ ├── preflib_util.py
│ │ ├── preflib_util_test.py
│ │ ├── ranked_pairs.py
│ │ ├── ranked_pairs_test.py
│ │ ├── schulze.py
│ │ ├── schulze_test.py
│ │ ├── soft_condorcet_optimization.py
│ │ ├── soft_condorcet_optimization_test.py
│ │ ├── stv.py
│ │ └── stv_test.py
├── rust
│ ├── CMakeLists.txt
│ ├── Cargo.toml
│ ├── README.md
│ ├── build.rs
│ └── src
│ │ ├── example.rs
│ │ ├── open_spiel_bindings.rs
│ │ ├── rust_open_spiel.cc
│ │ ├── rust_open_spiel.h
│ │ └── rust_open_spiel.rs
├── scripts
│ ├── argslib.sh
│ ├── build_and_run_tests.sh
│ ├── ci_python_prechecks.sh
│ ├── ci_script.sh
│ ├── find_jax.sh
│ ├── find_pytorch.sh
│ ├── find_tensorflow.sh
│ ├── generate_new_playthrough.sh
│ ├── global_variables.sh
│ ├── install.sh
│ ├── python_extra_deps.sh
│ ├── regenerate_playthroughs.sh
│ └── test_wheel.sh
├── simultaneous_move_game.cc
├── simultaneous_move_game.h
├── spiel.cc
├── spiel.h
├── spiel_bots.cc
├── spiel_bots.h
├── spiel_globals.h
├── spiel_utils.cc
├── spiel_utils.h
├── tensor_game.cc
├── tensor_game.h
├── tests
│ ├── CMakeLists.txt
│ ├── action_view_test.cc
│ ├── basic_tests.cc
│ ├── basic_tests.h
│ ├── console_play_test.cc
│ ├── console_play_test.h
│ ├── shared_lib_test.cc
│ └── spiel_test.cc
└── utils
│ ├── CMakeLists.txt
│ ├── circular_buffer.h
│ ├── circular_buffer_test.cc
│ ├── combinatorics.cc
│ ├── combinatorics.h
│ ├── combinatorics_test.cc
│ ├── data_logger.cc
│ ├── data_logger.h
│ ├── data_logger_test.cc
│ ├── file.cc
│ ├── file.h
│ ├── file_test.cc
│ ├── functional.h
│ ├── functional_test.cc
│ ├── init.cc
│ ├── init.h
│ ├── json.cc
│ ├── json.h
│ ├── json_test.cc
│ ├── logger.h
│ ├── logger_test.cc
│ ├── lru_cache.h
│ ├── lru_cache_test.cc
│ ├── random.cc
│ ├── random.h
│ ├── random_test.cc
│ ├── serializable_circular_buffer.h
│ ├── serializable_circular_buffer_test.cc
│ ├── serialization.h
│ ├── stats.h
│ ├── stats_test.cc
│ ├── tensor_view.h
│ ├── tensor_view_test.cc
│ ├── thread.cc
│ ├── thread.h
│ ├── thread_test.cc
│ ├── threaded_queue.h
│ ├── threaded_queue_test.cc
│ ├── usage_logging.cc
│ └── usage_logging.h
├── readthedocs.yml
├── requirements.txt
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Jupyter Notebook
10 | .ipynb_checkpoints
11 |
12 | # virtualenv
13 | .venv
14 | venv/
15 | ENV/
16 |
17 | # OSX specific
18 | .DS_Store
19 |
20 | # Build products
21 | build/
22 | build*/
23 | cmake-build-*/
24 | dist/
25 | pyspiel.egg-info/
26 | open_spiel.egg-info/
27 |
28 |
29 | # Swift build directory
30 | .build
31 |
32 | # External git modules
33 | open_spiel/abseil-cpp/
34 | open_spiel/eigen/libeigen/
35 | open_spiel/libnop/libnop/
36 | open_spiel/games/bridge/double_dummy_solver/
37 | open_spiel/games/universal_poker/double_dummy_solver/
38 | open_spiel/games/hanabi/hanabi-learning-environment/
39 | /open_spiel/pybind11_abseil/
40 | pybind11/
41 |
42 | # Install artifacts
43 | download_cache/
44 | get-pip.py
45 | open_spiel/scripts/shflags
46 | open_spiel/scripts/jill.sh
47 |
48 | # julia wrapper
49 | Manifest.toml
50 |
51 |
52 | # IDE
53 | .idea/
54 | .vscode/
55 | *~
56 |
57 |
58 | open_spiel/cmake-build-debug/
59 |
60 | # Swift generated build file
61 | Package.resolved
62 | # Visual Studio generated files
63 | open_spiel/.vs
64 | /.env
65 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to Contribute
2 |
3 | We'd love to accept your patches and contributions to this project. There are
4 | just a few small guidelines you need to follow.
5 |
6 | ## Contributor License Agreement
7 |
8 | Contributions to this project must be accompanied by a Contributor License
9 | Agreement. You (or your employer) retain the copyright to your contribution;
10 | this simply gives us permission to use and redistribute your contributions as
11 | part of the project. Head over to to see
12 | your current agreements on file or to sign a new one.
13 |
14 | You generally only need to submit a CLA once, so if you've already submitted one
15 | (even if it was for a different project), you probably don't need to do it
16 | again.
17 |
18 | ## Code reviews
19 |
20 | All submissions, including submissions by project members, require review. We
21 | use GitHub pull requests for this purpose. Consult
22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23 | information on using pull requests.
24 |
25 | ## Community Guidelines
26 |
27 | This project follows [Google's Open Source Community
28 | Guidelines](https://opensource.google.com/conduct/).
29 |
--------------------------------------------------------------------------------
/Dockerfile.jupyter:
--------------------------------------------------------------------------------
1 | FROM ubuntu:20.04 as base
2 | RUN apt update
3 | RUN apt-get -y install \
4 | clang \
5 | curl \
6 | git \
7 | python3 \
8 | python3-dev \
9 | python3-pip \
10 | python3-setuptools \
11 | python3-wheel \
12 | sudo
13 | RUN mkdir repo
14 | WORKDIR /repo
15 |
16 | RUN sudo pip3 install --upgrade pip
17 | RUN sudo pip3 install matplotlib
18 |
19 | # install
20 | COPY . .
21 | RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
22 | RUN ./install.sh
23 | RUN pip3 install --upgrade setuptools testresources
24 | RUN pip3 install --upgrade -r requirements.txt
25 | RUN pip3 install --upgrade cmake
26 |
27 | # build and test
28 | RUN mkdir -p build
29 | WORKDIR /repo/build
30 | RUN cmake -DPython_TARGET_VERSION=${PYVERSION} -DCMAKE_CXX_COMPILER=`which clang++` ../open_spiel
31 | RUN make -j12
32 | ENV PYTHONPATH=${PYTHONPATH}:/repo
33 | ENV PYTHONPATH=${PYTHONPATH}:/repo/build/python
34 | # ctest can be disabled for faster builds when tests are not required
35 | RUN ctest -j12
36 | WORKDIR /repo/open_spiel
37 |
38 | # Jupyterlab Environment
39 | FROM base as jupyterlab
40 | RUN pip install jupyter -U && pip install jupyterlab
41 | EXPOSE 8888
42 | ENTRYPOINT ["jupyter", "lab","--ip=0.0.0.0","--allow-root"]
43 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # python package requirements
2 | include requirements.txt
3 |
4 | # pybind files
5 | recursive-include pybind11/include/pybind11 *.h
6 | recursive-include pybind11/pybind11 *.py
7 | include pybind11/CMakeLists.txt
8 |
9 | # open_spiel files, including source files for abseil and dds
10 | recursive-include open_spiel CMakeLists.txt *.cc *.cpp *.h *.hpp *.py evalHandTables
11 |
12 | # abseil CMake files
13 | recursive-include open_spiel/abseil-cpp/CMake **
14 | recursive-include open_spiel/abseil-cpp/ *.cmake *.inc
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = open_spiel
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 | ./fix_table_links.sh
22 |
--------------------------------------------------------------------------------
/docs/_static/OpenSpielB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/OpenSpielB.png
--------------------------------------------------------------------------------
/docs/_static/alpha_sweep_plots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/alpha_sweep_plots.png
--------------------------------------------------------------------------------
/docs/_static/example_multi_population_game_rankings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/example_multi_population_game_rankings.png
--------------------------------------------------------------------------------
/docs/_static/green_circ10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/green_circ10.png
--------------------------------------------------------------------------------
/docs/_static/markov_chain_visualization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/markov_chain_visualization.png
--------------------------------------------------------------------------------
/docs/_static/passing.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/_static/public_tree_kuhn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google-deepmind/open_spiel/9ae2567ab2785ec04a7847e322616ea73cb8245b/docs/_static/public_tree_kuhn.png
--------------------------------------------------------------------------------
/docs/api_reference/game_action_to_string.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: action_to_string
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `action_to_string(player: int, action: int)`
7 |
8 | Returns a string representation of the specified player's action, independent of
9 | state.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | game = pyspiel.load_game("matrix_pd")
17 | print(game.action_to_string(0, 0))
18 | # Output: Cooperate
19 |
20 | # Print first player's second action (1).
21 | game = pyspiel.load_game("tic_tac_toe")
22 | print(game.action_to_string(0, 1))
23 | # Output: x(0, 1)
24 | ```
25 |
--------------------------------------------------------------------------------
/docs/api_reference/game_deserialize_game_and_state.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel core functions: deserialize_game_and_state
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `deserialize_game_and_state(game: pyspiel.Game, state: pyspiel.State)`
7 |
8 | Returns a (game, state) tuple that is reconstructed from the serialized string
9 | data.
10 |
11 | Note: pickle can also be used to serialize / deserialize data, and the pickle
12 | uses the same serialization methods.
13 |
14 | ## Examples:
15 |
16 | ```python
17 | import pyspiel
18 |
19 | game = pyspiel.load_game("tic_tac_toe")
20 | state = game.new_initial_state()
21 | state.apply_action(4)
22 | state.apply_action(2)
23 | state.apply_action(1)
24 | state.apply_action(5)
25 |
26 | serialized_data = pyspiel.serialize_game_and_state(game, state)
27 | print(serialized_data)
28 |
29 | game_copy, state_copy = pyspiel.deserialize_game_and_state(serialized_data)
30 | print(state_copy)
31 |
32 | # Output:
33 | # # Automatically generated by OpenSpiel SerializeGameAndState
34 | # [Meta]
35 | # Version: 1
36 | #
37 | # [Game]
38 | # tic_tac_toe()
39 | # [State]
40 | # 4
41 | # 2
42 | # 1
43 | # 5
44 | #
45 | #
46 | # .xo
47 | # .xo
48 | # ...
49 | ```
50 |
--------------------------------------------------------------------------------
/docs/api_reference/game_deserialize_state.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: deserialize_state
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `deserialize_state(serialized_data: str)`
7 |
8 | Reconstruct a state object from the state's serialized data (from
9 | `state.serialize()`). The game used to reconstruct must be the same as the game
10 | that created the original state.
11 |
12 | To serialize a state along with the game, use `pyspiel.serialize_game_and_state`
13 | instead.
14 |
15 | ## Examples:
16 |
17 | ```python
18 | import pyspiel
19 |
20 | game = pyspiel.load_game("tic_tac_toe")
21 | state = game.new_initial_state()
22 | state.apply_action(4)
23 | state.apply_action(2)
24 | state.apply_action(1)
25 | state.apply_action(5)
26 |
27 | state_copy = game.deserialize_state(state.serialize())
28 | print(state_copy)
29 |
30 | # Output:
31 | # .xo
32 | # .xo
33 | # ...
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/api_reference/game_information_state_tensor_shape_size.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: information_state_tensor_shape and information_state_tensor_size
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `information_state_tensor_shape()`
7 | 2. `information_state_tensor_size()`
8 |
9 | (1) Returns the information state tensor's shape: a list of integers
10 | representing the size of each dimension.
11 |
12 | (2) Returns the total number of values used to represent the information state
13 | tensor.
14 |
15 | ## Examples:
16 |
17 | ```python
18 | import pyspiel
19 |
20 | game = pyspiel.load_game("kuhn_poker")
21 | print(game.information_state_tensor_shape())
22 | print(game.information_state_tensor_size())
23 |
24 | # Output:
25 | # [11]
26 | # 11
27 | ```
28 |
--------------------------------------------------------------------------------
/docs/api_reference/game_max_chance_outcomes.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: max_chance_outcomes
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `max_chance_outcomes`
7 |
8 | Returns the maximum number of distinct chance outcomes at chance nodes in the
9 | game.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | game = pyspiel.load_game("chess")
17 | print(game.max_chance_outcomes())
18 | # Outputs: 0 (no chance nodes in Chess)
19 |
20 | game = pyspiel.load_game("markov_soccer")
21 | print(game.max_chance_outcomes())
22 | # Outputs: 4 (ball starting location, and who gets initiative)
23 |
24 | game = pyspiel.load_game("leduc_poker")
25 | print(game.max_chance_outcomes())
26 | # Outputs: 6 (three cards in two suits)
27 | ```
28 |
--------------------------------------------------------------------------------
/docs/api_reference/game_max_game_length.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: max_game_length
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `max_game_length()`
7 |
8 | The maximum length of any one game (in terms of number of decision nodes
9 | visited in the game tree).
10 |
11 | For a simultaneous action game, this is the maximum number of joint decisions.
12 | In a turn-based game, this is the maximum number of individual decisions summed
13 | over all players. Outcomes of chance nodes are not included in this length.
14 |
15 | ## Examples:
16 |
17 | ```python
18 | import pyspiel
19 |
20 | game = pyspiel.load_game("tic_tac_toe")
21 | print(game.max_game_length()) # Output: 9
22 |
23 | # Normal-form games always have one
24 | game = pyspiel.load_game("blotto")
25 | print(game.max_game_length()) # Output: 1
26 |
27 | # The maximum is arbitrarily defined (and/or customizable) is some games.
28 | game = pyspiel.load_game("coop_box_pushing")
29 | print(game.max_game_length()) # Output: 100
30 | game = pyspiel.load_game("coop_box_pushing(horizon=250)")
31 | print(game.max_game_length()) # Output: 250
32 | ```
33 |
--------------------------------------------------------------------------------
/docs/api_reference/game_max_min_utility.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: max_utility and min_utility
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `max_utility()` \
7 | `min_utility()`
8 |
9 | Returns the maximum and minimum achievable utility (return in any given episode)
10 | in the game.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | # Win/loss game
18 | game = pyspiel.load_game("tic_tac_toe")
19 | print(game.min_utility()) # Output: -1
20 | print(game.max_utility()) # Output: 1
21 |
22 | # Win/los/draw game (draw counts as 0).
23 | game = pyspiel.load_game("chess")
24 | print(game.min_utility()) # Output: -1
25 | print(game.max_utility()) # Output: 1
26 |
27 | # Money game.
28 | game = pyspiel.load_game("leduc_poked")
29 | print (game.num_distinct_actions())
30 | print(game.min_utility()) # Output: -13
31 | print(game.max_utility()) # Output: 13
32 | ```
33 |
--------------------------------------------------------------------------------
/docs/api_reference/game_new_initial_state.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: new_initial_state
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `new_initial_state()`
7 |
8 | Returns a new state object representing the first state of the game. Note, in
9 | particular, this might be a chance node (where the current player is chance) in
10 | games with chance events.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("hex")
18 | state = game.new_initial_state()
19 | print(state)
20 |
21 | # Output:
22 | # . . . . . . . . . . .
23 | # . . . . . . . . . . .
24 | # . . . . . . . . . . .
25 | # . . . . . . . . . . .
26 | # . . . . . . . . . . .
27 | # . . . . . . . . . . .
28 | # . . . . . . . . . . .
29 | # . . . . . . . . . . .
30 | # . . . . . . . . . . .
31 | # . . . . . . . . . . .
32 | # . . . . . . . . . . .
33 | ```
34 |
--------------------------------------------------------------------------------
/docs/api_reference/game_num_distinct_actions.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: num_distinct_actions
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `num_distinct_actions()`
7 |
8 | Returns the number of state-independent actions in the game. Valid actions in a
9 | game will always be between 0 and `num_distinct_actions() - 1`. This number can
10 | be thought of as the fixed width of a policy head or Q-network. Legal actions
11 | are always a subset of { 0, 1, ... , `num_distinct_actions() - 1` }.
12 |
13 | ## Examples:
14 |
15 | ```python
16 | import pyspiel
17 |
18 | game = pyspiel.load_game("tic_tac_toe")
19 | print(game.num_distinct_actions()) # Output: 9
20 |
21 | game = pyspiel.load_game("go")
22 | print (game.num_distinct_actions()) # Output: 362
23 |
24 | game = pyspiel.load_game("chess")
25 | print (game.num_distinct_actions()) # Output: 4672
26 |
27 | game = pyspiel.load_game("leduc_poker")
28 | print (game.num_distinct_actions()) # Output: 3
29 | ```
30 |
--------------------------------------------------------------------------------
/docs/api_reference/game_observation_tensor_shape_size.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel game methods: observation_tensor_shape and observation_tensor_size
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `observation_tensor_shape()`
7 | 2. `observation_tensor_size()`
8 |
9 | (1) Returns the observation tensor's shape: a list of integers representing the
10 | size of each dimension.
11 |
12 | (2) Returns the total number of values used to represent the observation tensor.
13 |
14 | ## Examples:
15 |
16 | ```python
17 | import pyspiel
18 |
19 | game = pyspiel.load_game("tic_tac_toe")
20 | print(game.observation_tensor_shape())
21 | print(game.observation_tensor_size())
22 |
23 | # Output:
24 | # [3, 3, 3]
25 | # 27
26 | ```
27 |
--------------------------------------------------------------------------------
/docs/api_reference/game_serialize_game_and_state.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel core functions: serialize_game_and_state
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `serialize_game_and_state(game: pyspiel.Game, state: pyspiel.State)`
7 |
8 | Returns a string representation of the state and the game that created it.
9 |
10 | Note: pickle can also be used to serialize / deserialize data, and the pickle
11 | uses the same serialization methods.
12 |
13 | ## Examples:
14 |
15 | ```python
16 | import pyspiel
17 |
18 | game = pyspiel.load_game("tic_tac_toe")
19 | state = game.new_initial_state()
20 | state.apply_action(4)
21 | state.apply_action(2)
22 | state.apply_action(1)
23 | state.apply_action(5)
24 |
25 | serialized_data = pyspiel.serialize_game_and_state(game, state)
26 | print(serialized_data)
27 |
28 | game_copy, state_copy = pyspiel.deserialize_game_and_state(serialized_data)
29 | print(state_copy)
30 |
31 | # Output:
32 | # # Automatically generated by OpenSpiel SerializeGameAndState
33 | # [Meta]
34 | # Version: 1
35 | #
36 | # [Game]
37 | # tic_tac_toe()
38 | # [State]
39 | # 4
40 | # 2
41 | # 1
42 | # 5
43 | #
44 | #
45 | # .xo
46 | # .xo
47 | # ...
48 | ```
49 |
--------------------------------------------------------------------------------
/docs/api_reference/load_game.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel functions: load_game
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `load_game(game_string: str)`
7 | 2. `load_game(game_string: str, parameters: Dict[str, Any])`
8 |
9 | Returns a newly-loaded game. The game string can be the short name of any game
10 | on its own, or the short name followed by a comma-separated list of `key=value`
11 | pairs within parentheses.
12 |
13 | ## Examples:
14 |
15 | ```python
16 | import pyspiel
17 |
18 | # Loads the game with no/default parameters.
19 | game1 = pyspiel.load_game("tic_tac_toe")
20 |
21 | # Loads the game with no/default parameters (8x8 Breakthrough)
22 | game2 = pyspiel.load_game("breakthrough")
23 |
24 | # Load a three-player Kuhn poker game.
25 | game3 = pyspiel.load_game("kuhn_poker(players=3)")
26 |
27 | # Load the imperfect information variant of Goofspiel with five cards, and the
28 | # unspecified parameters get their default values (two different ways):
29 | game4 = pyspiel.load_game("goofspiel(imp_info=True,num_cards=5,points_order=descending)")
30 | game5 = pyspiel.load_game("goofspiel", {
31 | "imp_info": True,
32 | "num_cards": 5,
33 | "points_order": "descending"
34 | })
35 | ```
36 |
--------------------------------------------------------------------------------
/docs/api_reference/registered_names.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel functions: registered_names
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `registered_names()`
7 |
8 | Returns a list of short names of all game in the library. These are names that
9 | can be used when loading games in `load_game`.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | # Print the name of all OpenSpiel games
17 | for short_name in pyspiel.registered_names():
18 | print(short_name)
19 | ```
20 |
--------------------------------------------------------------------------------
/docs/api_reference/state_action_to_string.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: action_to_string
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `action_to_string(player: int, action: int)`
7 |
8 | Returns a string representation of the specified player's action.
9 |
10 | ## Examples:
11 |
12 | ```python
13 | import pyspiel
14 |
15 | game = pyspiel.load_game("breakthrough")
16 | state = game.new_initial_state()
17 | player = state.current_player()
18 | for action in state.legal_actions():
19 | print(state.action_to_string(player, action))
20 | ```
21 |
--------------------------------------------------------------------------------
/docs/api_reference/state_chance_outcomes.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: chance_outcomes
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `chance_outcomes()`
7 |
8 | Returns a list of (action, probability) tuples representing the probability
9 | distribution over chance outcomes.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 | import numpy as np
16 |
17 | game = pyspiel.load_game("leduc_poker")
18 | state = game.new_initial_state()
19 |
20 | # First player's private card.
21 | print(state.chance_outcomes())
22 | # Output:
23 | # [(0, 0.16666666666666666), (1, 0.16666666666666666), (2, 0.16666666666666666), (3, 0.16666666666666666), (4, 0.16666666666666666), (5, 0.16666666666666666)]
24 | state.apply_action(0)
25 |
26 | # Second player's private card.
27 | outcomes = state.chance_outcomes()
28 | print()
29 | # Output:
30 | # [(1, 0.2), (2, 0.2), (3, 0.2), (4, 0.2), (5, 0.2)]
31 |
32 | # Sampling an outcome and applying it.
33 | action_list, prob_list = zip(*outcomes)
34 | action = np.random.choice(action_list, p=prob_list)
35 | state.apply_action(action)
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/api_reference/state_current_player.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: current_player
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `current_player()`
7 |
8 | Returns the player ID of the acting player. Player IDs for actual players start
9 | at 0 and end at `game.num_players() - 1`. There are some special player IDs that
10 | represent the chance player, simultaneous-move nodes, and terminal states.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("tic_tac_toe")
18 | state = game.new_initial_state()
19 | print(state.current_player()) # Output: 0
20 |
21 | game = pyspiel.load_game("leduc_poker")
22 | state = game.new_initial_state()
23 | print(state.current_player()) # Output: -1 (pyspiel.PlayerId.CHANCE)
24 |
25 | game = pyspiel.load_game("matrix_rps")
26 | state = game.new_initial_state()
27 | print(state.current_player()) # Output: -2 (pyspiel.PlayerId.SIMULTANEOUS)
28 | state.apply_actions([0, 0]) # I like to Rock! Oh yeah? Well.. so do I!
29 | print(state.current_player()) # Output: -4 (pyspiel.PlayerId.TERMINAL)
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/api_reference/state_history.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: history
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `history()`
7 |
8 | Returns a list of actions taken by all players (including chance) from the
9 | beginning of the game.
10 |
11 | In simultaneous-move games, joint actions are written out sequentially in player
12 | ID order.
13 |
14 | ## Examples:
15 |
16 | ```python
17 | import pyspiel
18 |
19 | game = pyspiel.load_game("kuhn_poker")
20 | state = game.new_initial_state()
21 | state.apply_action(0) # First player gets the Jack
22 | state.apply_action(1) # Second player gets the Queen
23 | state.apply_action(0) # First player passes (check)
24 | state.apply_action(1) # Second player bets (raise)
25 |
26 | print(state.history())
27 | # Output: [0, 1, 0, 1]
28 |
29 | game = pyspiel.load_game("matrix_pd")
30 | state = game.new_initial_state()
31 | state.apply_actions([0, 1]) # Cooperate, Defect
32 | print(state.history())
33 | # Output: [0, 1]
34 | ```
35 |
--------------------------------------------------------------------------------
/docs/api_reference/state_information_state_string.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: information_state_string
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `information_state_string()`
7 | 2. `information_state_string(player: int)`
8 |
9 | Returns a string representation of the information state, for (1) the current
10 | player, or (2) the specified player.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("kuhn_poker")
18 | state = game.new_initial_state()
19 | state.apply_action(0) # Deal first player the Jack,
20 | state.apply_action(1) # and second player the Queen
21 | state.apply_action(0) # First player passes (check)
22 | state.apply_action(1) # Second player bets (raise)
23 |
24 | # Player 0's turn.
25 | print(state.information_state_string())
26 | print(state.information_state_string(1))
27 |
28 | # Output:
29 | # 0pb
30 | # 1pb
31 | ```
32 |
--------------------------------------------------------------------------------
/docs/api_reference/state_information_state_tensor.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: information_state_tensor
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `information_state_tensor()`
7 | 2. `information_state_tensor(player: int)`
8 |
9 | Returns information state tensor (a list of values) for (1) the current player,
10 | or (2) the specified player.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("kuhn_poker")
18 | state = game.new_initial_state()
19 | state.apply_action(0) # Deal first player the Jack,
20 | state.apply_action(1) # and second player the Queen
21 | state.apply_action(0) # First player passes (check)
22 | state.apply_action(1) # Second player bets (raise)
23 |
24 | # Player 0's turn.
25 | print(state.information_state_tensor())
26 | print(state.information_state_tensor(1))
27 |
28 | # Tensors differ in the observing player and the card obtained.
29 | # Output:
30 | # [1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
31 | # [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
32 | ```
33 |
--------------------------------------------------------------------------------
/docs/api_reference/state_is_chance_node.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: is_chance_node
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `is_chance_node()`
7 |
8 | Returns True if the state represents a chance node, False otherwise.
9 |
10 | ## Examples:
11 |
12 | ```python
13 | import pyspiel
14 |
15 | game = pyspiel.load_game("tic_tac_toe")
16 | state = game.new_initial_state()
17 | print(state.is_chance_node()) # Output: False
18 |
19 | game = pyspiel.load_game("leduc_poker")
20 | state = game.new_initial_state()
21 | print(state.is_chance_node()) # Output: True
22 |
23 | game = pyspiel.load_game("matrix_sh")
24 | state = game.new_initial_state()
25 | print(state.is_chance_node()) # Output: False
26 | ```
27 |
--------------------------------------------------------------------------------
/docs/api_reference/state_is_simultaneous_node.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: is_simultaneous_node
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `is_simultaneous_node()`
7 |
8 | Returns True if the state represents a simultaneous player node (where all
9 | players act simultaneously), False otherwise.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | game = pyspiel.load_game("tic_tac_toe")
17 | state = game.new_initial_state()
18 | print(state.is_simultaneous_node()) # Output: False
19 |
20 | game = pyspiel.load_game("matrix_mp")
21 | state = game.new_initial_state()
22 | print(state.is_simultaneous_node()) # Output: True
23 |
24 | # Simultaneous-move game that start at a chance node.
25 | game = pyspiel.load_game("markov_soccer")
26 | state = game.new_initial_state()
27 | print(state.is_simultaneous_node()) # Output: False
28 | print(state.legal_actions())
29 | state.apply_action(state.legal_actions()[0]) # Apply first legal chance outcome.
30 | print(state.is_simultaneous_node()) # Output: True
31 |
32 | ```
33 |
--------------------------------------------------------------------------------
/docs/api_reference/state_is_terminal.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: is_terminal
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `is_terminal()`
7 |
8 | Returns True if the state is terminal (the game has ended), False otherwise.
9 |
10 | ## Examples:
11 |
12 | ```python
13 | import pyspiel
14 |
15 | game = pyspiel.load_game("tic_tac_toe")
16 | state = game.new_initial_state()
17 | print(state.is_terminal()) # Output: False
18 |
19 | game = pyspiel.load_game("matrix_rps")
20 | state = game.new_initial_state()
21 | print(state.is_terminal()) # Output: False
22 | state.apply_actions([1, 1])
23 | print(state.is_terminal()) # Output: True
24 | ```
25 |
--------------------------------------------------------------------------------
/docs/api_reference/state_legal_actions.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: legal_actions
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `legal_actions()`
7 | 2. `legal_actions(player: int)`
8 |
9 | Returns the list of legal actions (integers between 0 and
10 | `game.num_distinct_actions() - 1`) for (1) the current player, or (2) the
11 | specified player.
12 |
13 | When called on a chance node, returns the legal chance outcomes without their
14 | corresponding probabilities.
15 |
16 | When called on a simultaneous node, returns the set of legal joint actions
17 | represented as flat integers, which can then be passed to `apply_action`.
18 |
19 | ## Examples:
20 |
21 | ```python
22 | import pyspiel
23 |
24 | game = pyspiel.load_game("tic_tac_toe")
25 | state = game.new_initial_state()
26 | print(state.legal_actions())
27 | # Output: [0, 1, 2, 3, 4, 5, 6, 7, 8]
28 |
29 | game = pyspiel.load_game("matrix_pd")
30 | state = game.new_initial_state()
31 | print(state.legal_actions(0)) # row player
32 | print(state.legal_actions(1)) # column player
33 | # Output:
34 | # [0, 1]
35 | # [0, 1]
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/api_reference/state_observation_string.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: observation_string
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `observation_string()`
7 | 2. `observation_string(player: int)`
8 |
9 | Returns a string representation of the observation, for (1) the current player,
10 | or (2) the specified player.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("breakthrough")
18 | state = game.new_initial_state()
19 | print(state.action_to_string(0, 148)) # Output: e7f6
20 | state.apply_action(148)
21 |
22 | print(state.observation_string())
23 | # Output:
24 | # 8bbbbbbbb
25 | # 7bbbb.bbb
26 | # 6.....b..
27 | # 5........
28 | # 4........
29 | # 3........
30 | # 2wwwwwwww
31 | # 1wwwwwwww
32 | # abcdefgh
33 |
34 | # Perfect information game, same observation for both players.
35 | print(state.observation_string(0))
36 | # Output:
37 | # 8bbbbbbbb
38 | # 7bbbb.bbb
39 | # 6.....b..
40 | # 5........
41 | # 4........
42 | # 3........
43 | # 2wwwwwwww
44 | # 1wwwwwwww
45 | # abcdefgh
46 | ```
47 |
--------------------------------------------------------------------------------
/docs/api_reference/state_observation_tensor.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: observation_tensor
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | 1. `observation_tensor()`
7 | 2. `observation_tensor(player: int)`
8 |
9 | Returns observation tensor (a list of values) for (1) the current player, or (2)
10 | the specified player.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 | import numpy as np
17 |
18 | game = pyspiel.load_game("tic_tac_toe")
19 | state = game.new_initial_state()
20 | state.apply_action(4) # Middle
21 | state.apply_action(2) # Top-right
22 |
23 | # Player 0's turn.
24 | shape = game.observation_tensor_shape()
25 | print(state.observation_tensor())
26 | print(state.observation_tensor(0))
27 |
28 | # First dimension interpreted as selecting from 2D planes of { empty, O, X }.
29 | print(np.reshape(np.asarray(state.observation_tensor()), shape))
30 |
31 | # Output:
32 | # [1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
33 | # [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
34 | # [[[1. 1. 0.]
35 | # [1. 0. 1.]
36 | # [1. 1. 1.]]
37 | #
38 | # [[0. 0. 1.]
39 | # [0. 0. 0.]
40 | # [0. 0. 0.]]
41 | #
42 | # [[0. 0. 0.]
43 | # [0. 1. 0.]
44 | # [0. 0. 0.]]]
45 | ```
46 |
--------------------------------------------------------------------------------
/docs/api_reference/state_returns.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: returns
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `returns()`
7 |
8 | Returns the list of returns (cumulated reward from the start of the game): one
9 | value per player.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | game = pyspiel.load_game("tic_tac_toe")
17 | state = game.new_initial_state()
18 |
19 | # Play out a win for 'x'.
20 | state.apply_action(4)
21 | state.apply_action(1)
22 | state.apply_action(2)
23 | state.apply_action(5)
24 | state.apply_action(6)
25 | print(state)
26 | print(state.returns())
27 |
28 | # Output:
29 | # .ox
30 | # .xo
31 | # x..
32 | # [1.0, -1.0]
33 | ```
34 |
--------------------------------------------------------------------------------
/docs/api_reference/state_rewards.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: rewards
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `rewards()`
7 |
8 | Returns the list of intermediate rewards (rewards obtained since the last time
9 | the player acted): one value per player. Note that for many games in OpenSpiel,
10 | this function will return zeroes unless the state is terminal.
11 |
12 | ## Examples:
13 |
14 | ```python
15 | import pyspiel
16 |
17 | game = pyspiel.load_game("matrix_pd")
18 | state = game.new_initial_state()
19 |
20 | # Defect, Defect
21 | state.apply_actions([1, 1])
22 |
23 | # Rewards and returns equal in this case
24 | print(state.rewards())
25 | print(state.returns())
26 |
27 | # Output:
28 | # [1.0, 1.0]
29 | # [1.0, 1.0]
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/api_reference/state_serialize.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel state methods: serialize
2 |
3 | [Back to Core API reference](../api_reference.md) \
4 |
5 |
6 | `serialize()`
7 |
8 | Returns a string representation of the state be used to reconstruct the state.
9 | By default, it is a string list of each action taken in the history.
10 |
11 | ## Examples:
12 |
13 | ```python
14 | import pyspiel
15 |
16 | game = pyspiel.load_game("tic_tac_toe")
17 | state = game.new_initial_state()
18 | state.apply_action(4)
19 | state.apply_action(2)
20 | state.apply_action(1)
21 | state.apply_action(5)
22 |
23 | state_copy = game.deserialize_state(state.serialize())
24 | print(state_copy)
25 |
26 | # Output:
27 | # .xo
28 | # .xo
29 | # ...
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/authors.md:
--------------------------------------------------------------------------------
1 | # Authors
2 |
3 | Names are ordered lexicographically. Typo or similar contributors are omitted.
4 |
5 | ## OpenSpiel contributors
6 |
7 | - Bart De Vylder
8 | - Edward Hughes
9 | - Edward Lockhart
10 | - Daniel Hennes
11 | - David Ding
12 | - Dustin Morrill
13 | - Elnaz Davoodi
14 | - Finbarr Timbers
15 | - Ivo Danihelka
16 | - Jean-Baptiste Lespiau
17 | - Janos Kramar
18 | - Jonah Ryan-Davis
19 | - Julian Schrittwieser
20 | - Julien Perolat
21 | - Karl Tuyls
22 | - Manuel Kroiss
23 | - Marc Lanctot
24 | - Matthew Lai
25 | - Michal Sustr
26 | - Raphael Marinier
27 | - Paul Muller
28 | - Ryan Faulkner
29 | - Satyaki Upadhyay
30 | - Sebastian Borgeaud
31 | - Sertan Girgin
32 | - Shayegan Omidshafiei
33 | - Srinivasan Sriram
34 | - Thomas Anthony
35 | - Thomas Köppe
36 | - Timo Ewalds
37 | - Vinicius Zambaldi
38 |
39 | ## OpenSpiel with Swift for Tensorflow (now removed)
40 |
41 | - James Bradbury
42 | - Brennan Saeta
43 | - Dan Zheng
44 |
45 | ## External contributors
46 |
47 | See https://github.com/deepmind/open_spiel/graphs/contributors.
48 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to OpenSpiel's documentation!
2 | --------------------------------------
3 |
4 |
5 | .. toctree:: :caption: Getting started
6 | :maxdepth: 2
7 |
8 | intro
9 | install
10 |
11 |
12 | .. toctree:: :caption: Core OpenSpiel
13 | :maxdepth: 2
14 |
15 | concepts
16 | api_reference
17 | algorithms
18 | games
19 |
20 | .. toctree:: :caption: Evaluation
21 | :maxdepth: 2
22 |
23 | Alpha-Rank
24 |
25 | .. toctree:: :caption: Julia OpenSpiel
26 | :maxdepth: 2
27 |
28 | OpenSpiel on Julia
29 |
30 | .. toctree:: :caption: AlphaZero
31 | :maxdepth: 2
32 |
33 | alpha_zero
34 |
35 | .. toctree:: :caption: Developer guide
36 | :maxdepth: 2
37 |
38 | developer_guide
39 | contributing
40 |
41 | .. toctree:: :caption: Using OpenSpiel as a C++ Library
42 | :maxdepth: 2
43 |
44 | library
45 |
46 | .. toctree:: :caption: Extra information
47 | :maxdepth: 2
48 |
49 | authors
50 |
--------------------------------------------------------------------------------
/docs/requirements.readthedocs.txt:
--------------------------------------------------------------------------------
1 | # These are the dependencies to generate the documentation.
2 | markdown==3.4
3 | recommonmark==0.7.1
4 | sphinx_markdown_tables==0.0.17
5 | sphinx==5.1
6 | sphinx-rtd-theme==1.3.0
7 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Just a stub here in the root to reference the real install script.
18 | source $(dirname "$0")/open_spiel/scripts/install.sh
19 |
--------------------------------------------------------------------------------
/open_spiel/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # The existence of this file allows us to have PYTHONPATH pointing to
16 | # the parent of this directory and then use:
17 | # from open_spiel.python import rl_environment
18 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/alpha_zero_torch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # To enable C++ Torch AlphaZero, you will need to set OPEN_SPIEL_BUILD_WITH_LIBTORCH.
2 | if (OPEN_SPIEL_BUILD_WITH_LIBTORCH)
3 | if(NOT OPEN_SPIEL_BUILD_WITH_LIBNOP)
4 | message(FATAL_ERROR
5 | "alpha_zero_torch requires libnop (OPEN_SPIEL_BUILD_WITH_LIBNOP)")
6 | endif()
7 |
8 | add_library (alpha_zero_torch OBJECT
9 | alpha_zero.h
10 | alpha_zero.cc
11 | device_manager.h
12 | model.h
13 | model.cc
14 | vpevaluator.h
15 | vpevaluator.cc
16 | vpnet.h
17 | vpnet.cc
18 | )
19 | target_include_directories (alpha_zero_torch PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
20 |
21 | add_executable(torch_model_test model_test.cc ${OPEN_SPIEL_OBJECTS}
22 | $ $)
23 | add_test(torch_model_test torch_model_test)
24 |
25 | add_executable(torch_vpnet_test vpnet_test.cc ${OPEN_SPIEL_OBJECTS}
26 | $ $)
27 | add_test(torch_vpnet_test torch_vpnet_test)
28 |
29 | target_link_libraries (alpha_zero_torch ${TORCH_LIBRARIES})
30 | target_link_libraries (torch_model_test ${TORCH_LIBRARIES})
31 | target_link_libraries (torch_vpnet_test ${TORCH_LIBRARIES})
32 | endif ()
33 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/dqn_torch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # To enable C++ Torch DQN, you will need to set OPEN_SPIEL_BUILD_WITH_LIBTORCH.
2 | if (OPEN_SPIEL_BUILD_WITH_LIBTORCH)
3 | add_library (dqn_torch OBJECT
4 | dqn.h
5 | dqn.cc
6 | simple_nets.h
7 | simple_nets.cc
8 | )
9 | target_include_directories (dqn_torch PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
10 |
11 | add_executable(dqn_torch_test dqn_torch_test.cc ${OPEN_SPIEL_OBJECTS}
12 | $ $)
13 | add_test(dqn_torch_test dqn_torch_test)
14 |
15 | target_link_libraries(dqn_torch ${TORCH_LIBRARIES})
16 | target_link_libraries(dqn_torch_test ${TORCH_LIBRARIES})
17 | endif()
18 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/get_all_infostates.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_ALGORITHMS_GET_ALL_INFOSTATES_H_
16 | #define OPEN_SPIEL_ALGORITHMS_GET_ALL_INFOSTATES_H_
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "open_spiel/spiel.h"
23 |
24 | namespace open_spiel {
25 | namespace algorithms {
26 |
27 | // Get all the information states in the game. Currently works for sequential
28 | // games. Use -1 for the depth_limit to get everything.
29 | std::vector> GetAllInformationStates(
30 | const Game& game, int depth_limit = -1);
31 |
32 | } // namespace algorithms
33 | } // namespace open_spiel
34 |
35 | #endif // OPEN_SPIEL_ALGORITHMS_GET_ALL_INFOSTATES_H_
36 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/get_all_states_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/algorithms/get_all_states.h"
16 |
17 | #include "open_spiel/games/tic_tac_toe/tic_tac_toe.h"
18 | #include "open_spiel/spiel_utils.h"
19 |
20 | namespace algorithms = open_spiel::algorithms;
21 | namespace ttt = open_spiel::tic_tac_toe;
22 |
23 | int main(int argc, char **argv) {
24 | std::shared_ptr game =
25 | open_spiel::LoadGame("tic_tac_toe");
26 | auto states = algorithms::GetAllStates(*game, -1, /*include_terminals=*/true,
27 | /*include_chance_states=*/true);
28 | SPIEL_CHECK_EQ(states.size(), ttt::kNumberStates);
29 | }
30 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/maxn.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_ALGORITHMS_MAXN_H_
16 | #define OPEN_SPIEL_ALGORITHMS_MAXN_H_
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "open_spiel/spiel.h"
23 |
24 | namespace open_spiel {
25 | namespace algorithms {
26 |
27 | std::pair, Action> MaxNSearch(
28 | const Game& game, const State* state,
29 | std::function value_function,
30 | int depth_limit);
31 |
32 | } // namespace algorithms
33 | } // namespace open_spiel
34 |
35 | #endif // OPEN_SPIEL_ALGORITHMS_MAXN_H_
36 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/nfg_writer.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_ALGORITHMS_NFG_WRITER_H_
16 | #define OPEN_SPIEL_ALGORITHMS_NFG_WRITER_H_
17 |
18 | #include
19 |
20 | #include "open_spiel/spiel.h"
21 |
22 | namespace open_spiel {
23 |
24 | // Functions to export normal-form games to Gambit's .nfg format.
25 | // http://www.gambit-project.org/gambit13/formats.html#the-strategic-game-nfg-file-format-payoff-version
26 |
27 | // Get the string representation of this normal-form game.
28 | const std::string GameToNFGString(const Game& game);
29 |
30 | } // namespace open_spiel
31 |
32 | #endif // OPEN_SPIEL_ALGORITHMS_NFG_WRITER_H_
33 |
--------------------------------------------------------------------------------
/open_spiel/algorithms/ortools/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This is an optional dependency. Currently it is only tested with the binary
2 | # release of OR-Tools v8 on Linux x86_64 (Debian 10).
3 | #
4 | # You need to set OPEN_SPIEL_BUILD_WITH_ORTOOLS to ON to include C++ Linear Programming.
5 | # See the main ../../CMakeLists for more instructions for setup, and
6 | # https://github.com/deepmind/open_spiel/issues/398 for details and discussion
7 | # of C++ optimization in OpenSpiel.
8 |
9 | add_library(open_spiel_ortools OBJECT
10 | lp_solver.cc
11 | lp_solver.h
12 | sequence_form_lp.cc
13 | sequence_form_lp.h
14 | )
15 | target_link_libraries(open_spiel_ortools ${ORTOOLS_LIBS})
16 |
17 | add_executable(lp_solver_test lp_solver_test.cc ${OPEN_SPIEL_OBJECTS}
18 | $ $)
19 | target_link_libraries(lp_solver_test ${ORTOOLS_LIBS})
20 | add_test(lp_solver_test lp_solver_test)
21 |
22 | add_executable(sequence_form_lp_test sequence_form_lp_test.cc
23 | ${OPEN_SPIEL_OBJECTS}
24 | $ $)
25 | target_link_libraries(sequence_form_lp_test ${ORTOOLS_LIBS})
26 | add_test(sequence_form_lp_test sequence_form_lp_test)
27 |
--------------------------------------------------------------------------------
/open_spiel/bots/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set (BOT_SOURCES
2 | gin_rummy/simple_gin_rummy_bot.cc
3 | gin_rummy/simple_gin_rummy_bot.h
4 | human/human_bot.cc
5 | human/human_bot.h
6 | )
7 |
8 | if (NOT WIN32)
9 | # UCI bot not supported on Windows.
10 | set (BOT_SOURCES ${BOT_SOURCES}
11 | uci/uci_bot.cc
12 | uci/uci_bot.h
13 | )
14 | endif()
15 |
16 | add_library (bots OBJECT ${BOT_SOURCES})
17 |
18 | add_subdirectory(gin_rummy)
19 | add_subdirectory(human)
20 |
21 | if (NOT WIN32)
22 | # UCI bot not supported on Windows.
23 | add_subdirectory(uci)
24 | endif()
25 |
26 | if (OPEN_SPIEL_BUILD_WITH_ROSHAMBO)
27 | add_subdirectory(roshambo)
28 | endif()
29 |
30 | if (OPEN_SPIEL_BUILD_WITH_XINXIN)
31 | add_subdirectory(xinxin)
32 | endif()
33 |
34 |
--------------------------------------------------------------------------------
/open_spiel/bots/gin_rummy/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable (simple_gin_rummy_bot_example simple_gin_rummy_bot_example.cc
2 | ${OPEN_SPIEL_OBJECTS})
3 |
4 | add_executable (simple_gin_rummy_bot_test simple_gin_rummy_bot_test.cc
5 | ${OPEN_SPIEL_OBJECTS} $)
6 | add_test(simple_gin_rummy_bot_test simple_gin_rummy_bot_test)
7 |
--------------------------------------------------------------------------------
/open_spiel/bots/human/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable (human_bot_test human_bot_test.cc ${OPEN_SPIEL_OBJECTS}
2 | $)
3 | add_test(human_bot_test human_bot_test)
4 |
--------------------------------------------------------------------------------
/open_spiel/bots/human/human_bot.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_BOTS_HUMAN_HUMAN_BOT_H_
16 | #define OPEN_SPIEL_BOTS_HUMAN_HUMAN_BOT_H_
17 |
18 | #include "open_spiel/spiel_bots.h"
19 |
20 | namespace open_spiel {
21 |
22 | class HumanBot : public Bot {
23 | public:
24 | Action Step(const State &state);
25 | };
26 |
27 | } // namespace open_spiel
28 |
29 | #endif // OPEN_SPIEL_BOTS_HUMAN_HUMAN_BOT_H_
30 |
--------------------------------------------------------------------------------
/open_spiel/bots/roshambo/README.md:
--------------------------------------------------------------------------------
1 | # RoShamBo Bots
2 |
3 | Bots from the International RoShamBo Programming Competition, available as an
4 | optional dependency. See `open_spiel/scripts/global_variables.sh` to configure
5 | conditional dependencies and enable this.
6 |
7 | The competition was held in 1999 and 2000 by Darse Billings at the University of
8 | Alberta. The player pool was seeded with dummy bots, requiring competitive
9 | entrants to exploit sub-optimal play while avoiding getting exploited by other
10 | sophisticated bots. For more information, and all code used in the first
11 | competition, see https://webdocs.cs.ualberta.ca/~darse/rsbpc.html.
12 |
13 | No additional code from the second competition was officially released, but
14 | Andrzej Nagorko, author of the winning entrant Greenberg, independently released
15 | the bot’s source code http://www.mathpuzzle.com/older.htm. Greenberg is also
16 | included as an OpenSpiel bot.
17 |
--------------------------------------------------------------------------------
/open_spiel/bots/uci/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_executable(random_uci_bot random_uci_bot.cc ${OPEN_SPIEL_OBJECTS}
3 | $)
4 |
5 | add_executable(uci_bot_test uci_bot_test.cc ${OPEN_SPIEL_OBJECTS}
6 | $)
7 | add_test(NAME uci_bot_test
8 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/uci_bot_test
9 | --binary ${CMAKE_CURRENT_BINARY_DIR}/random_uci_bot)
10 |
--------------------------------------------------------------------------------
/open_spiel/bots/xinxin/.gitignore:
--------------------------------------------------------------------------------
1 | # This directory is fetched during install, do not include in OpenSpiel.
2 | hearts/
3 |
--------------------------------------------------------------------------------
/open_spiel/bots/xinxin/README.md:
--------------------------------------------------------------------------------
1 | # Hearts
2 |
3 | OpenSpiel can support playing against Nathan Sturtevant's state of the art
4 | Hearts program xinxin (pronounced "sheen-sheen"). To enable this option, see
5 | `open_spiel/scripts/global_variables.sh`.
6 |
7 | For more information about xinxin, see its
8 | [github page](https://github.com/nathansttt/hearts) and/or
9 | [Nathan's Hearts research page](https://webdocs.cs.ualberta.ca/~nathanst/hearts.html).
10 |
--------------------------------------------------------------------------------
/open_spiel/bots/xinxin/xinxin_pybind11.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/bots/xinxin/xinxin_bot.h"
16 | #include "open_spiel/spiel_bots.h"
17 | #include "open_spiel/python/pybind11/pybind11.h"
18 |
19 | namespace open_spiel {
20 |
21 | namespace py = ::pybind11;
22 |
23 | void init_pyspiel_xinxin(::pybind11::module& m) {
24 | m.def("make_xinxin_bot", open_spiel::hearts::MakeXinxinBot, py::arg("params"),
25 | py::arg("uct_num_runs") = 50, py::arg("uct_c_val") = 0.4,
26 | py::arg("iimc_num_worlds") = 20, py::arg("use_threads") = true,
27 | "Make the XinXin bot.");
28 | }
29 |
30 | } // namespace open_spiel
31 |
--------------------------------------------------------------------------------
/open_spiel/bots/xinxin/xinxin_pybind11.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_BOTS_XINXIN_XINXIN_PYBIND11_H_
16 | #define OPEN_SPIEL_BOTS_XINXIN_XINXIN_PYBIND11_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | namespace open_spiel {
21 | void init_pyspiel_xinxin(::pybind11::module& m);
22 | } // namespace open_spiel
23 |
24 | #endif // OPEN_SPIEL_BOTS_XINXIN_XINXIN_PYBIND11_H_
25 |
--------------------------------------------------------------------------------
/open_spiel/data/paper_data/README.md:
--------------------------------------------------------------------------------
1 | # Paper data
2 |
3 | This directory hosts data for reproducing paper results. Each paper should have
4 | an associated directory, with data contained within.
5 |
--------------------------------------------------------------------------------
/open_spiel/data/paper_data/pbe_rrps/README.md:
--------------------------------------------------------------------------------
1 | The `bot_table_file.txt` is a data set described in
2 | [Population-based Evaluation in Repeated RPS as a Benchmark for Multiagent RL](https://arxiv.org/abs/2303.03196)
3 | and parsed by `python/examples/roshambo_population_example.py`.
4 |
5 | It contains a cross-table of the expected values for all possible match-ups
6 | between the 43 RRPS bots, using an average of 1000 games per cell.
7 |
--------------------------------------------------------------------------------
/open_spiel/data/paper_data/routing_game_experiments/readme.md:
--------------------------------------------------------------------------------
1 | # Reproducing routing game experiments
2 |
3 | To reproduce the experiments done in [*Solving N-player dynamic routing games
4 | with congestion: a mean field approach, Cabannes et.
5 | al.*](https://dl.acm.org/doi/10.5555/3535850.3536033):
6 |
7 | 1. If you have not, download [python](https://www.python.org/downloads/) and an
8 | IDE to run iPython notebook (either [jupyter](https://jupyter.org) or
9 | [VSCode](https://code.visualstudio.com)).
10 | 2. Install OpenSpiel using
11 | [pip install open_spiel](https://github.com/deepmind/open_spiel/blob/master/docs/install.md)
12 | or from
13 | [source](https://github.com/deepmind/open_spiel/blob/master/docs/install.md#installation-from-source).
14 | 3. Download the
15 | [`Experiments.ipynb` iPython notebook](https://github.com/deepmind/open_spiel/tree/master/open_spiel/data/paper_data/routing_game_experiments/Experiments.ipynb).
16 | 4. Run the iPython notebook. You might need to download the dependant python
17 | libraries.
18 |
19 | # License
20 |
21 | This code is under the Open Spiel license. Please cite the paper [*Solving
22 | N-player dynamic routing games with congestion: a mean field approach, Cabannes
23 | et. al.*](https://dl.acm.org/doi/10.5555/3535850.3536033) when re-using this
24 | code. Feel free to send an email to theophile@berkeley.edu for any questions.
25 |
--------------------------------------------------------------------------------
/open_spiel/evaluation/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library (evaluation OBJECT
2 | soft_condorcet_optimization.cc
3 | soft_condorcet_optimization.h
4 | )
5 | target_include_directories (evaluation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
6 |
7 | add_executable(soft_condorcet_optimization_test soft_condorcet_optimization_test.cc
8 | $ ${OPEN_SPIEL_OBJECTS})
9 | add_test(soft_condorcet_optimization_test soft_condorcet_optimization_test)
10 |
--------------------------------------------------------------------------------
/open_spiel/game_transforms/add_noise_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/game_transforms/add_noise.h"
16 |
17 | #include "open_spiel/spiel.h"
18 | #include "open_spiel/tests/basic_tests.h"
19 |
20 | namespace open_spiel {
21 | namespace add_noise {
22 | namespace {
23 |
24 | namespace testing = open_spiel::testing;
25 |
26 | void BasicTests() {
27 | testing::LoadGameTest("add_noise(epsilon=1.,seed=1,game=kuhn_poker())");
28 | testing::RandomSimTest(
29 | *LoadGame("add_noise(epsilon=1.,seed=1,game=kuhn_poker())"), 100);
30 | }
31 |
32 | } // namespace
33 | } // namespace add_noise
34 | } // namespace open_spiel
35 |
36 | int main(int argc, char** argv) { open_spiel::add_noise::BasicTests(); }
37 |
--------------------------------------------------------------------------------
/open_spiel/game_transforms/coop_to_1p_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/game_transforms/coop_to_1p.h"
16 |
17 | #include "open_spiel/spiel.h"
18 | #include "open_spiel/tests/basic_tests.h"
19 |
20 | namespace open_spiel {
21 | namespace coop_to_1p {
22 | namespace {
23 |
24 | namespace testing = open_spiel::testing;
25 |
26 | void BasicTests() {
27 | testing::LoadGameTest("coop_to_1p(game=tiny_hanabi())");
28 | testing::RandomSimTest(*LoadGame("coop_to_1p(game=tiny_hanabi())"),
29 | 100);
30 | }
31 |
32 | } // namespace
33 | } // namespace coop_to_1p
34 | } // namespace open_spiel
35 |
36 | int main(int argc, char** argv) { open_spiel::coop_to_1p::BasicTests(); }
37 |
--------------------------------------------------------------------------------
/open_spiel/game_transforms/misere_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/game_transforms/misere.h"
16 |
17 | #include "open_spiel/spiel.h"
18 | #include "open_spiel/tests/basic_tests.h"
19 |
20 | namespace open_spiel {
21 | namespace misere {
22 | namespace {
23 |
24 | namespace testing = open_spiel::testing;
25 |
26 | void BasicMisereTests() {
27 | testing::LoadGameTest("misere(game=kuhn_poker())");
28 | testing::NoChanceOutcomesTest(*LoadGame("misere(game=tic_tac_toe())"));
29 | testing::RandomSimTest(*LoadGame("misere(game=leduc_poker())"), 100);
30 | }
31 |
32 | } // namespace
33 | } // namespace misere
34 | } // namespace open_spiel
35 |
36 | int main(int argc, char** argv) { open_spiel::misere::BasicMisereTests(); }
37 |
--------------------------------------------------------------------------------
/open_spiel/game_transforms/zerosum_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/game_transforms/zerosum.h"
16 |
17 | #include "open_spiel/games/oh_hell/oh_hell.h"
18 | #include "open_spiel/spiel.h"
19 | #include "open_spiel/tests/basic_tests.h"
20 |
21 | namespace open_spiel {
22 | namespace zerosum {
23 | namespace {
24 |
25 | namespace testing = open_spiel::testing;
26 |
27 | void BasicZeroSumTests() {
28 | testing::LoadGameTest("zerosum(game=oh_hell(off_bid_penalty=true))");
29 | testing::RandomSimTest(
30 | *LoadGame("zerosum(game=oh_hell(off_bid_penalty=true))"), 10);
31 | }
32 |
33 | } // namespace
34 | } // namespace zerosum
35 | } // namespace open_spiel
36 |
37 | int main(int argc, char** argv) { open_spiel::zerosum::BasicZeroSumTests(); }
38 |
--------------------------------------------------------------------------------
/open_spiel/games/dou_dizhu/dou_dizhu_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/games/dou_dizhu/dou_dizhu.h"
16 |
17 | #include "open_spiel/spiel.h"
18 | #include "open_spiel/tests/basic_tests.h"
19 |
20 | namespace open_spiel {
21 | namespace dou_dizhu {
22 | namespace {
23 |
24 | void BasicGameTests() {
25 | testing::LoadGameTest("dou_dizhu");
26 | testing::RandomSimTest(*LoadGame("dou_dizhu"), 20);
27 | }
28 |
29 | } // namespace
30 | } // namespace dou_dizhu
31 | } // namespace open_spiel
32 |
33 | int main() {
34 | open_spiel::dou_dizhu::BasicGameTests();
35 | }
36 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/README.md:
--------------------------------------------------------------------------------
1 | This directory contains files that are in the
2 | [Gambit](http://www.gambit-project.org/)
3 | [extensive-form game (.efg) format](http://www.gambit-project.org/gambit14/formats.html).
4 |
5 | To load them, use game string `efg_game(filename=)`.
6 | The parser is found in [efg_game.h](https://github.com/deepmind/open_spiel/blob/master/open_spiel/games/efg_game.h).
7 |
8 | To export existing games in the library into gambit format, you can use python
9 | script `python/examples/gambit_example.py`
10 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/commas.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "commas" { "p1" "p2" }
2 | "test different allowed commas in payoffs"
3 |
4 | p "" 1 1 "" { "A" "B" } 0
5 | c "" 1 "" { "s" 99/100 "c" 1/100 } 0
6 | p "" 2 1 "" { "S" "C" } 0
7 | t "" 1 "SS" { 5, 2, }
8 | t "" 2 "SC" { 3 1 }
9 | p "" 2 2 "" { "S" "C" } 0
10 | t "" 1 "SS" { 5 2, }
11 | t "" 2 "SC" { 3, 1 }
12 | c "" 2 "" { "s" 1/100 "c" 99/100 } 0
13 | p "" 2 1 "" { "S" "C" } 0
14 | t "" 3 "CS" { 6, 3, }
15 | t "" 4 "CC" { 4, 4 }
16 | p "" 2 2 "" { "S" "C" } 0
17 | t "" 3 "CS" { 6, 3 }
18 | t "" 4 "CC" { 4, 4 }
19 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/extended_bos.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "Modified Battle-of-the-Sexes Game in Morrill et al., Hindsight and Sequential Rationality of Correlated Play" { "Player 1" "Player 2" } ""
2 |
3 | p "ROOT" 1 1 "Root infoset" { "U" "N" } 0
4 | p "U" 1 2 "P1 U" { "X" "Y" } 0
5 | p "UX" 2 1 "P2 Infoset" { "X" "Y" } 0
6 | t "UXX" 1 "Outcome UXX" { 2.0 3.0 }
7 | t "UXY" 2 "Outcome UXY" { 0.0 0.0 }
8 | p "UY" 2 1 "P2 Infoset" { "X" "Y" } 0
9 | t "UYX" 3 "Outcome UYX" { 0.0 0.0 }
10 | t "UYY" 4 "Outcome UYY" { 3.0 2.0 }
11 | p "N" 1 3 "P1 N" { "X" "Y" } 0
12 | p "NX" 2 1 "P2 Infoset" { "X" "Y" } 0
13 | t "NXX" 5 "Outcome NXX" { 1.0 2.0 }
14 | t "NXY" 6 "Outcome NXY" { 0.0 0.0 }
15 | p "NY" 2 1 "P2 Infoset" { "X" "Y" } 0
16 | t "NYX" 7 "Outcome NYX" { 0.0 0.0 }
17 | t "NYY" 8 "Outcome NYY" { 2.0 1.0 }
18 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/extended_mp.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "Modified Matching Pennies Game in Morrill et al., Hindsight and Sequential Rationality of Correlated Play" { "Player 1" "Player 2" } ""
2 |
3 | p "ROOT" 1 1 "Root infoset" { "M" "N" } 0
4 | p "M" 1 2 "P1 M" { "H" "T" } 0
5 | p "MH" 2 1 "P2 Infoset" { "H" "T" } 0
6 | t "MHH" 1 "Outcome MHH" { 1.0 -1.0 }
7 | t "MHT" 2 "Outcome UXY" { -1.0 1.0 }
8 | p "MT" 2 1 "P2 Infoset" { "H" "T" } 0
9 | t "MTH" 3 "Outcome MTH" { -1.0 1.0 }
10 | t "MTT" 4 "Outcome MTT" { 1.0 -1.0 }
11 | p "N" 1 3 "P1 N" { "H" "T" } 0
12 | p "NH" 2 1 "P2 Infoset" { "H" "T" } 0
13 | t "NHH" 5 "Outcome NHH" { -1.0 1.0 }
14 | t "NHT" 6 "Outcome NHT" { 1.0 -1.0 }
15 | p "NT" 2 1 "P2 Infoset" { "H" "T" } 0
16 | t "NTH" 7 "Outcome NTH" { 1.0 -1.0 }
17 | t "NTT" 8 "Outcome NTT" { -1.0 1.0 }
18 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/greenwald_sarfati_example1.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "Greenwald & Sarfati Example 1" { "Player 1" "Player 2" } "Example AFCE / AFCCE that is not an EFCE nor EFCCE"
2 |
3 | p "ROOT" 1 1 "Root infoset" { "L" "R" } 0
4 | p "L" 2 1 "P2 infoset" { "A" "B" } 0
5 | p "LA" 1 2 "Left P1 infoset" { "l1" "r1" } 0
6 | t "LAl" 1 "Outcome LAl" { 2.0 2.0 }
7 | t "LAr" 2 "Outcome LAr" { 3.0 1.0 }
8 | p "LB" 1 2 "Left P1 infoset" { "l1" "r1" } 0
9 | t "LBl" 3 "Outcome LBl" { 2.0 2.0 }
10 | t "LBr" 4 "Outcome LBr" { 0.0 2.0 }
11 | p "R" 2 1 "P2 infoset" { "A" "B" } 0
12 | p "RA" 1 3 "Right P1 infoset" { "l2" "r2" } 0
13 | t "RAl" 5 "Outcome RAl" { 0.0 0.0 }
14 | t "RAr" 6 "Outcome RAr" { 3.0 0.0 }
15 | p "RB" 1 3 "Right P1 infoset" { "l2" "r2" } 0
16 | t "RBl" 7 "Outcome RBl" { 0.0 0.0 }
17 | t "RBr" 8 "Outcome RBr" { 3.0 0.0 }
18 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/greenwald_sarfati_example2.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "Greenwald & Sarfati Example 1" { "Player 1" "Player 2" } "Example EFCE but not CE"
2 |
3 | p "ROOT" 1 1 "Root infoset" { "L" "R" } 0
4 | p "L" 2 1 "P2 infoset" { "A" "B" } 0
5 | p "LA" 1 2 "Left P1 infoset" { "l1" "r1" } 0
6 | t "LAl" 1 "Outcome LAl" { 2.0 2.0 }
7 | t "LAr" 2 "Outcome LAr" { 0.0 2.0 }
8 | p "LB" 1 2 "Left P1 infoset" { "l1" "r1" } 0
9 | t "LBl" 3 "Outcome LBl" { 2.0 2.0 }
10 | t "LBr" 4 "Outcome LBr" { 2.0 2.0 }
11 | p "R" 2 1 "P2 infoset" { "A" "B" } 0
12 | p "RA" 1 3 "Right P1 infoset" { "l2" "r2" } 0
13 | t "RAl" 5 "Outcome RAl" { 0.0 0.0 }
14 | t "RAr" 6 "Outcome RAr" { 0.0 0.0 }
15 | p "RB" 1 3 "Right P1 infoset" { "l2" "r2" } 0
16 | t "RBl" 7 "Outcome RBl" { 0.0 0.0 }
17 | t "RBr" 8 "Outcome RBr" { 3.0 0.0 }
18 |
--------------------------------------------------------------------------------
/open_spiel/games/efg_game/games/signaling_vonstengel_forges_2008.efg:
--------------------------------------------------------------------------------
1 | EFG 2 R "Signaling game from Fig 1 of von Stengel and Forges 2008" { "Player 1" "Player 2" } "See Fig 1 of Extensive-Form Correlated Equilibrium:
2 | Definition and Computational Complexity"
3 |
4 | c "ROOT" 1 "c1" { "g" 1/2 "b" 1/2 } 0
5 | p "G" 1 1 "G" { "X_G" "Y_G" } 0
6 | p "G X_G" 2 1 "X" { "l_X" "r_X" } 0
7 | t "G X_G l_X" 1 "Outcome G X_G l_X" { 4.0 10.0 }
8 | t "G X_G r_X" 2 "Outcome G X_G r_X" { 0.0 6.0 }
9 | p "G Y_G" 2 2 "Y" { "l_Y" "r_Y" } 0
10 | t "G Y_G l_Y" 3 "Outcome G Y_G l_Y" { 4.0 10.0 }
11 | t "G Y_G r_Y" 4 "Outcome G Y_G r_Y" { 0.0 6.0 }
12 | p "B" 1 2 "B" { "X_B" "Y_B" } 0
13 | p "B X_B" 2 1 "X" { "l_X" "r_X" } 0
14 | t "B X_B l_X" 5 "Outcome B X_B l_X" { 6.0 0.0 }
15 | t "B X_B r_X" 6 "Outcome B X_B r_X" { 0.0 6.0 }
16 | p "B Y_B" 2 2 "Y" { "l_Y" "r_Y" } 0
17 | t "B Y_B l_Y" 7 "Outcome B Y_B l_Y" { 6.0 0.0 }
18 | t "B Y_B r_Y" 8 "Outcome B Y_B r_Y" { 0.0 6.0 }
19 |
--------------------------------------------------------------------------------
/open_spiel/games/gamut/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The interface to GAMUT is optional. To enable it, set the flag in
2 | # scripts/global_variables.sh.
3 |
4 | add_library(gamut OBJECT
5 | gamut.cc
6 | gamut.h
7 | )
8 |
9 | add_executable (gamut_test gamut_test.cc ${OPEN_SPIEL_OBJECTS}
10 | $)
11 | add_test(gamut_test gamut_test)
12 |
--------------------------------------------------------------------------------
/open_spiel/games/gamut/README.md:
--------------------------------------------------------------------------------
1 | # GAMUT games
2 |
3 | This is an interface to load normal-form games from the
4 | [GAMUT](http://gamut.stanford.edu/) games generator. This interface is not
5 | compiled with OpenSpiel by default and must be enabled via the
6 | `OPEN_SPIEL_BUILD_WITH_GAMUT` environment variable (see the Developer Guide)
7 | when OpenSpiel is built.
8 |
9 | It requires a working JVM (`java` binary) and the `gamut.jar` from the GAMUT
10 | project.
11 |
12 | Note that this interface is not regularly tested, so it may break at any time.
13 | Please open an issue to report any problem when using it.
14 |
--------------------------------------------------------------------------------
/open_spiel/games/gamut/gamut_pybind11.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_GAMES_GAMUT_GAMUT_PYBIND11_H_
16 | #define OPEN_SPIEL_GAMES_GAMUT_GAMUT_PYBIND11_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | namespace open_spiel {
21 | void init_pyspiel_gamut(::pybind11::module& m);
22 | } // namespace open_spiel
23 |
24 | #endif // OPEN_SPIEL_GAMES_GAMUT_GAMUT_PYBIND11_H_
25 |
--------------------------------------------------------------------------------
/open_spiel/games/hanabi/README.md:
--------------------------------------------------------------------------------
1 | # Hanabi
2 |
3 | OpenSpiel can support Hanabi, using the implementation in
4 | https://github.com/deepmind/hanabi-learning-environment. To enable this option,
5 | see `open_spiel/scripts/global_variables.sh`.
6 |
--------------------------------------------------------------------------------
/open_spiel/games/matching_pennies_3p/matching_pennies_3p_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/spiel.h"
16 | #include "open_spiel/tests/basic_tests.h"
17 |
18 | namespace open_spiel {
19 | namespace matching_pennies_3p {
20 | namespace {
21 |
22 | namespace testing = open_spiel::testing;
23 |
24 | void BasicMatchingPennies3pTests() {
25 | testing::LoadGameTest("matching_pennies_3p");
26 | testing::NoChanceOutcomesTest(*LoadGame("matching_pennies_3p"));
27 | testing::RandomSimTest(*LoadGame("matching_pennies_3p"), 100);
28 | }
29 |
30 | } // namespace
31 | } // namespace matching_pennies_3p
32 | } // namespace open_spiel
33 |
34 | int main(int argc, char** argv) {
35 | open_spiel::matching_pennies_3p::BasicMatchingPennies3pTests();
36 | }
37 |
--------------------------------------------------------------------------------
/open_spiel/games/mnk/mnk_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/spiel.h"
16 | #include "open_spiel/tests/basic_tests.h"
17 |
18 | namespace open_spiel {
19 | namespace mnk {
20 | namespace {
21 |
22 | namespace testing = open_spiel::testing;
23 |
24 | void BasicMNKTests() {
25 | testing::LoadGameTest("mnk");
26 | testing::NoChanceOutcomesTest(*LoadGame("mnk"));
27 | testing::RandomSimTest(*LoadGame("mnk"), 100);
28 | }
29 |
30 | } // namespace
31 | } // namespace mnk
32 | } // namespace open_spiel
33 |
34 | int main(int argc, char** argv) { open_spiel::mnk::BasicMNKTests(); }
35 |
--------------------------------------------------------------------------------
/open_spiel/games/nfg_game/games/matching_pennies_3p.nfg:
--------------------------------------------------------------------------------
1 | NFG 1 R "OpenSpiel export of matching_pennies_3p()"
2 | { "Player 0" "Player 1" "Player 2" } { 2 2 2 }
3 |
4 | 1 1 -1
5 | -1 1 1
6 | -1 -1 -1
7 | 1 -1 1
8 | 1 -1 1
9 | -1 -1 -1
10 | -1 1 1
11 | 1 1 -1
12 |
--------------------------------------------------------------------------------
/open_spiel/games/nfg_game/games/sample.nfg:
--------------------------------------------------------------------------------
1 | NFG 1 R "Selten (IJGT, 75), Figure 2, normal form"
2 | { "Player 1" "Player 2" } { 3 2 }
3 |
4 | 1 1 0 2 0 2 1 1 0 3 2 0
5 |
--------------------------------------------------------------------------------
/open_spiel/games/nfg_game/nfg_game.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_GAMES_NFG_GAME_H_
16 | #define OPEN_SPIEL_GAMES_NFG_GAME_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "open_spiel/spiel.h"
22 |
23 | namespace open_spiel {
24 | namespace nfg_game {
25 |
26 | // A Gambit .NFG file reader. Currently only the payoff version is supported.
27 | // See http://www.gambit-project.org/gambit13/formats.html for details.
28 | std::shared_ptr LoadNFGGame(const std::string& data);
29 |
30 | } // namespace nfg_game
31 | } // namespace open_spiel
32 |
33 | #endif // OPEN_SPIEL_GAMES_NFG_GAME_H_
34 |
--------------------------------------------------------------------------------
/open_spiel/games/othello/othello_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/spiel.h"
16 | #include "open_spiel/tests/basic_tests.h"
17 |
18 | namespace open_spiel {
19 | namespace othello {
20 | namespace {
21 |
22 | namespace testing = open_spiel::testing;
23 |
24 | void BasicOthelloTests() {
25 | testing::LoadGameTest("othello");
26 | testing::NoChanceOutcomesTest(*LoadGame("othello"));
27 | testing::RandomSimTest(*LoadGame("othello"), 100);
28 | }
29 |
30 | } // namespace
31 | } // namespace othello
32 | } // namespace open_spiel
33 |
34 | int main(int argc, char** argv) {
35 | open_spiel::othello::BasicOthelloTests();
36 | }
37 |
--------------------------------------------------------------------------------
/open_spiel/games/skat/skat_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/games/skat/skat.h"
16 |
17 | #include "open_spiel/spiel_utils.h"
18 | #include "open_spiel/tests/basic_tests.h"
19 |
20 | namespace open_spiel {
21 | namespace skat {
22 | namespace {
23 |
24 | namespace testing = open_spiel::testing;
25 |
26 | void BasicSkatTests() {
27 | testing::LoadGameTest("skat");
28 | testing::RandomSimTest(*LoadGame("skat"), 10);
29 | }
30 |
31 | } // namespace
32 | } // namespace skat
33 | } // namespace open_spiel
34 |
35 | int main(int argc, char **argv) {
36 | open_spiel::skat::BasicSkatTests();
37 | }
38 |
--------------------------------------------------------------------------------
/open_spiel/games/tic_tac_toe/tic_tac_toe_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/spiel.h"
16 | #include "open_spiel/tests/basic_tests.h"
17 |
18 | namespace open_spiel {
19 | namespace tic_tac_toe {
20 | namespace {
21 |
22 | namespace testing = open_spiel::testing;
23 |
24 | void BasicTicTacToeTests() {
25 | testing::LoadGameTest("tic_tac_toe");
26 | testing::NoChanceOutcomesTest(*LoadGame("tic_tac_toe"));
27 | testing::RandomSimTest(*LoadGame("tic_tac_toe"), 100);
28 | }
29 |
30 | } // namespace
31 | } // namespace tic_tac_toe
32 | } // namespace open_spiel
33 |
34 | int main(int argc, char** argv) {
35 | open_spiel::tic_tac_toe::BasicTicTacToeTests();
36 | }
37 |
--------------------------------------------------------------------------------
/open_spiel/games/ultimate_tic_tac_toe/ultimate_tic_tac_toe_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/spiel.h"
16 | #include "open_spiel/tests/basic_tests.h"
17 |
18 | namespace open_spiel {
19 | namespace ultimate_tic_tac_toe {
20 | namespace {
21 |
22 | namespace testing = open_spiel::testing;
23 |
24 | void BasicUltimateTicTacToeTests() {
25 | testing::LoadGameTest("ultimate_tic_tac_toe");
26 | testing::NoChanceOutcomesTest(*LoadGame("ultimate_tic_tac_toe"));
27 | testing::RandomSimTest(*LoadGame("ultimate_tic_tac_toe"), 100);
28 | }
29 |
30 | } // namespace
31 | } // namespace ultimate_tic_tac_toe
32 | } // namespace open_spiel
33 |
34 | int main(int argc, char** argv) {
35 | open_spiel::ultimate_tic_tac_toe::BasicUltimateTicTacToeTests();
36 | }
37 |
--------------------------------------------------------------------------------
/open_spiel/games/universal_poker/.gitignore:
--------------------------------------------------------------------------------
1 | acpc/
2 |
--------------------------------------------------------------------------------
/open_spiel/games/universal_poker/README.md:
--------------------------------------------------------------------------------
1 | # Universal Poker support
2 |
3 | This has been contributed by dennisjay in November 2019 (See
4 | https://github.com/deepmind/open_spiel/pull/97), and is available as an optional
5 | dependency. See the [install.md](/docs/install.md) for documentation
6 | and `open_spiel/scripts/global_variables.sh` to enable this.
7 |
8 | This is a wrapper around the Annual Computer Poker Competition bot (ACPC)
9 | environment. See http://www.computerpokercompetition.org/. The code is initially
10 | available at https://github.com/ethansbrown/acpc
11 |
12 | Thanks to dennisjay for contributing this to the community! If it's useful to
13 | you, feel free to help supporting it. It has not been extensively reviewed or
14 | tested by the DeepMind OpenSpiel team.
15 |
--------------------------------------------------------------------------------
/open_spiel/games/universal_poker/logic/gamedef.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_GAMES_UNIVERSAL_POKER_LOGIC_GAMEDEF_H_
16 | #define OPEN_SPIEL_GAMES_UNIVERSAL_POKER_LOGIC_GAMEDEF_H_
17 |
18 | #include
19 |
20 | namespace open_spiel {
21 | namespace universal_poker {
22 | namespace logic {
23 |
24 | // Converts an ACPC gamedef into the corresponding string that's compatible with
25 | // OpenSpiel.
26 | std::string GamedefToOpenSpielParameters(const std::string& acpc_gamedef);
27 |
28 | } // namespace logic
29 | } // namespace universal_poker
30 | } // namespace open_spiel
31 |
32 | #endif // OPEN_SPIEL_GAMES_UNIVERSAL_POKER_LOGIC_GAMEDEF_H_
33 |
--------------------------------------------------------------------------------
/open_spiel/go/README.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel Go API
2 |
3 | *Note:* This API has issues and is no longer maintained. See
4 | [issue 1301](https://github.com/google-deepmind/open_spiel/issues/1301) for
5 | details.
6 |
7 | This is a basic [Go](https://golang.org/) API for OpenSpiel. Please note that it
8 | is currently experimental and may not work as expected. Please see the
9 | [announcement thread](https://github.com/deepmind/open_spiel/issues/541) and
10 | report any issues. Fixes and improvements are more than welcome!
11 |
12 | See the `CMakeLists.txt` to see how it is setup: a dynamic shared library is
13 | created similarly to python extension (`libgospiel.so`). A simple go module is
14 | created in this directory using `go mod init` so that go tests can be run. Note
15 | that currently `LD_LIBRARY_PATH` must include the location of the dynamic
16 | library so that it gets properly loaded at run time.
17 |
--------------------------------------------------------------------------------
/open_spiel/go/examples/example.go:
--------------------------------------------------------------------------------
1 | // Package main provides a simple example use of the Go API.
2 | package main
3 |
4 | import (
5 | "fmt"
6 |
7 | "math/rand"
8 |
9 | "openspiel"
10 | )
11 |
12 | func main() {
13 |
14 | openspiel.Test()
15 |
16 | game := openspiel.LoadGame("breakthrough")
17 | fmt.Printf("Game's long name is %s\n", game.LongName())
18 |
19 | state := game.NewInitialState()
20 |
21 | for !state.IsTerminal() {
22 | fmt.Printf("\n%s", state.String())
23 |
24 | curPlayer := state.CurrentPlayer()
25 | legalActions := state.LegalActions()
26 | for i := 0; i < len(legalActions); i++ {
27 | fmt.Printf("Legal action: %s\n", state.ActionToString(curPlayer, legalActions[i]))
28 | }
29 |
30 | sampledIdx := rand.Intn(len(legalActions))
31 | sampledAction := legalActions[sampledIdx]
32 | fmt.Printf("Sampled action: %s\n", state.ActionToString(curPlayer, sampledAction))
33 |
34 | state.ApplyAction(sampledAction)
35 | }
36 |
37 | fmt.Printf("\nTerminal state reached!\n")
38 | fmt.Printf(state.String())
39 | fmt.Printf("\n")
40 | for i := 0; i < game.NumPlayers(); i++ {
41 | fmt.Printf("Return for player %d is %f\n", i, state.PlayerReturn(i))
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/open_spiel/integration_tests/README.md:
--------------------------------------------------------------------------------
1 | # Integration tests
2 |
3 | This directory regroups high level tests, often testing both the C++ code and
4 | its Python bindings.
5 |
6 |
--------------------------------------------------------------------------------
/open_spiel/integration_tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/integration_tests/example_connect_four_state.txt:
--------------------------------------------------------------------------------
1 | .......
2 | .......
3 | .......
4 | ...o...
5 | ..oxx..
6 | .oxxo..
7 |
--------------------------------------------------------------------------------
/open_spiel/julia/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(JlCxx REQUIRED)
2 |
3 | add_library(spieljl SHARED wrapper/spieljl.cc ${OPEN_SPIEL_OBJECTS})
4 | target_link_libraries(spieljl PRIVATE JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl)
5 | set_target_properties(spieljl PROPERTIES
6 | CXX_STANDARD 17
7 | CXX_STANDARD_REQUIRED ON
8 | CXX_EXTENSIONS ON
9 | )
10 |
11 | install(TARGETS spieljl
12 | RUNTIME DESTINATION lib
13 | ARCHIVE DESTINATION lib
14 | LIBRARY DESTINATION lib
15 | )
16 |
17 | add_test(NAME julia_test COMMAND julia --project=${CMAKE_CURRENT_SOURCE_DIR}
18 | -e "using Pkg; Pkg.build(); Pkg.test()")
19 |
--------------------------------------------------------------------------------
/open_spiel/julia/Project.toml:
--------------------------------------------------------------------------------
1 | name = "OpenSpiel"
2 | uuid = "7e5d8dc8-489f-4be6-9273-f4c3010e6ec1"
3 | authors = ["Jun Tian "]
4 | version = "0.1.1"
5 |
6 | [deps]
7 | CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
8 |
9 | [compat]
10 | CxxWrap = "0.11.2"
11 | julia = "1.3"
12 |
13 | [extras]
14 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15 | StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
16 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17 |
18 | [targets]
19 | test = ["StatsBase", "Test", "Random"]
20 |
--------------------------------------------------------------------------------
/open_spiel/julia/README.md:
--------------------------------------------------------------------------------
1 | # Julia OpenSpiel
2 |
3 | For general usage, please refer
4 | [OpenSpiel on Julia](https://openspiel.readthedocs.io/en/latest/julia.html).
5 |
6 | For developers, the basic idea of this Julia wrapper is that, a shared lib named
7 | `libspieljl.so` is built with the help of
8 | [CxxWrap.jl](https://github.com/JuliaInterop/CxxWrap.jl) and then it is wrapped
9 | in the `OpenSpiel` module.
10 |
11 |
--------------------------------------------------------------------------------
/open_spiel/julia/deps/deps.jl:
--------------------------------------------------------------------------------
1 | const LIB_OPEN_SPIEL = "$(dirname(@__FILE__))/../../../build/julia/libspieljl"
2 |
--------------------------------------------------------------------------------
/open_spiel/julia/src/OpenSpiel.jl:
--------------------------------------------------------------------------------
1 | module OpenSpiel
2 |
3 | include("$(@__DIR__)/../deps/deps.jl")
4 |
5 | using CxxWrap
6 | import CxxWrap:argument_overloads
7 | import Base: step, first, last
8 |
9 | struct PlayerAction
10 | player::Int32
11 | action::Int64
12 | end
13 |
14 | @wrapmodule(LIB_OPEN_SPIEL)
15 |
16 | include("patch.jl")
17 |
18 | # export all
19 | for n in names(@__MODULE__(); all=true)
20 | if Base.isidentifier(n) &&
21 | !startswith(String(n), "_") &&
22 | n ∉ (Symbol(@__MODULE__()), :eval, :include)
23 | @eval export $n
24 | end
25 | end
26 |
27 |
28 | function __init__()
29 | @initcxx
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/open_spiel/julia/test/cfr.jl:
--------------------------------------------------------------------------------
1 | @testset "cfr" begin
2 |
3 | function test_nash_kuhn_poker(game, policy)
4 | game_values = expected_returns(new_initial_state(game), policy, -1)
5 |
6 | # 1/18 is the Nash value. See https://en.wikipedia.org/wiki/Kuhn_poker
7 | nash_value = 1.0 / 18.0
8 | eps = 1e-3
9 | @test length(game_values) == 2
10 | @test isapprox(game_values[1], -nash_value, atol=eps)
11 | @test isapprox(game_values[2], nash_value, atol=eps)
12 | end
13 |
14 | test_exploitability_kuhn_poker(game, policy) = @test exploitability(game, policy) <= 0.05
15 |
16 | @testset "CFRSolver" begin
17 | game = load_game("kuhn_poker")
18 | solver = CFRSolver(game)
19 | for _ in 1:300
20 | evaluate_and_update_policy(solver)
21 | end
22 | avg_policy = average_policy(solver)
23 | test_nash_kuhn_poker(game, avg_policy)
24 | test_exploitability_kuhn_poker(game, avg_policy)
25 | end
26 |
27 | @testset "CFRPlusSolver" begin
28 | game = load_game("kuhn_poker")
29 | solver = CFRPlusSolver(game)
30 | for _ in 1:200
31 | evaluate_and_update_policy(solver)
32 | end
33 | avg_policy = average_policy(solver)
34 | test_nash_kuhn_poker(game, avg_policy)
35 | test_exploitability_kuhn_poker(game, avg_policy)
36 | end
37 |
38 | end
39 |
--------------------------------------------------------------------------------
/open_spiel/julia/test/trajector.jl:
--------------------------------------------------------------------------------
1 | @testset "Trajectory" begin
2 |
3 | function get_states_to_indices(game)
4 | state_index = StdMap{StdString, Cint}()
5 | to_visit = []
6 | push!(to_visit, new_initial_state(game))
7 | i = 0
8 | while length(to_visit) != 0
9 | state = pop!(to_visit)
10 | if (!is_chance_node(state)) && (!is_terminal(state))
11 | state_index[information_state_string(state)] = Cint(i)
12 | end
13 | i += 1
14 | for action in legal_actions(state)
15 | push!(to_visit, child(state, action))
16 | end
17 | end
18 | state_index
19 | end
20 |
21 | @testset "BatchedTrajectory" begin
22 | for game_name in ["kuhn_poker", "leduc_poker", "liars_dice"]
23 | game = load_game(game_name)
24 | batch_size = 32
25 | states_to_inds = get_states_to_indices(game)
26 | policies = StdVector([get_uniform_policy(game) for _ in 1:2])
27 | t = record_batched_trajectories(game, policies, states_to_inds, batch_size, false, 123, -1)
28 | @test length(legal_actions(t)) == batch_size
29 | @test length(actions(t)) == batch_size
30 | @test length(player_policies(t)) == batch_size
31 | @test length(player_ids(t)) == batch_size
32 | @test length(next_is_terminal(t)) == batch_size
33 | end
34 | end
35 |
36 | end
37 |
--------------------------------------------------------------------------------
/open_spiel/libnop/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # An integration test to make sure that we can link with libnop.
2 | add_executable(libnop_integration_test
3 | libnop_integration_test.cc ${OPEN_SPIEL_OBJECTS})
4 | add_test(libnop_integration_test libnop_integration_test)
5 |
--------------------------------------------------------------------------------
/open_spiel/libtorch/.gitignore:
--------------------------------------------------------------------------------
1 | libtorch/
2 |
--------------------------------------------------------------------------------
/open_spiel/libtorch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Now we can use #include "open_spiel/spiel.h"
2 | include_directories(../..)
3 |
4 | # An integration test to make sure that we can link with torchlib.
5 | add_executable(torch_integration_test
6 | torch_integration_test.cc ${OPEN_SPIEL_OBJECTS})
7 | add_test(torch_integration_test torch_integration_test)
8 |
9 | target_link_libraries(torch_integration_test ${TORCH_LIBRARIES})
10 |
--------------------------------------------------------------------------------
/open_spiel/libtorch/torch_integration_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Examples of how to use the C++ API:
16 | // - https://github.com/pytorch/examples/tree/master/cpp
17 | // - https://github.com/prabhuomkar/pytorch-cpp
18 |
19 | #include "open_spiel/spiel_utils.h"
20 | #include "torch/torch.h"
21 |
22 | namespace {
23 |
24 | void TestMatrixMultiplication() {
25 | at::Tensor mat = torch::rand({3, 3});
26 | at::Tensor identity = torch::ones({3, 3});
27 | at::Tensor multiplied = mat * identity;
28 | int num_identical_elements = (mat == multiplied).sum().item().to();
29 | SPIEL_CHECK_EQ(num_identical_elements, 9);
30 | }
31 |
32 | } // namespace
33 |
34 | int main() { TestMatrixMultiplication(); }
35 |
--------------------------------------------------------------------------------
/open_spiel/python/README.md:
--------------------------------------------------------------------------------
1 | # Open Spiel Python API
2 |
3 | This is a Python API for OpenSpiel.
4 |
5 | See `python/examples/example.py` for an example use and overview of the API, and
6 | the main OpenSpiel installation instructions to see how to run this example.
7 |
8 | For the full API specification, please see `python/pybind11/pyspiel.cc`.
9 |
--------------------------------------------------------------------------------
/open_spiel/python/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Open Spiel Python API."""
16 |
17 | from typing import Dict, Union
18 |
19 | # A type provided for PyType hints. Added after the discussion in
20 | # https://github.com/google-deepmind/open_spiel/issues/1224.
21 | GameParameter = Union[int, float, str, bool, Dict[str, 'GameParameter']]
22 |
23 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/games/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/helpers/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/helpers/nonsymmetric/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/helpers/symmetric/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/solvers/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/solvers/nonsymmetric/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/adidas_utils/solvers/symmetric/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/alpha_zero/README.md:
--------------------------------------------------------------------------------
1 | ## Python AlphaZero
2 |
3 | This is a pure python implementation of the AlphaZero algorithm.
4 |
5 | Note: this version is based on Tensorflow V1 and is no longer maintained.
6 |
7 | For more information, please take a look at the
8 | [full documentation](https://github.com/deepmind/open_spiel/blob/master/docs/alpha_zero.md).
9 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/alpha_zero/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/psro_v2/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/algorithms/tf/README.md:
--------------------------------------------------------------------------------
1 | This directory contains old implementations of old algorithms based on
2 | Tensorflow V1. As of OpenSpiel 1.6, they are no longer maintained, but still
3 | provided here for reference.
4 |
--------------------------------------------------------------------------------
/open_spiel/python/bots/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/coalitional_games/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/egt/README.md:
--------------------------------------------------------------------------------
1 | # Open Spiel Evolutionary Game Theory (EGT) Toolbox
2 |
3 | This is a library for conducting Evolutionary Game Theory (EGT) analysis of
4 | games.
5 |
6 | ## A Breakdown of the code
7 |
8 | The following code implements Alpha-Rank, a multi-agent evaluation algorithm
9 | detailed in `α-Rank: Multi-Agent Evaluation by Evolution (2019)`, available at:
10 | https://www.nature.com/articles/s41598-019-45619-9.
11 |
12 | * `alpharank.py`: core implementation
13 | * `alpharank_visualizer.py`: Alpha-Rank plotting tools
14 |
15 | The following are utility scripts:
16 |
17 | * `heuristic_payoff_table.py`: defines a class for storing heuristic payoff
18 | tables for games (e.g., as detailed in `A Generalised Method for Empirical
19 | Game Theoretic Analysis` (Tuyls et al., 2018))
20 | * `utils.py`: helper functions
21 |
--------------------------------------------------------------------------------
/open_spiel/python/egt/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/egt/examples/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/environments/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/meta_cfr/sequential_games/evaluation.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Evaluation of a CFR best response agent given the world state."""
16 |
17 | from absl import flags
18 | FLAGS = flags.FLAGS
19 |
20 |
21 | def CFRBREvaluation(agent, world_state):
22 | return agent.next_policy(world_state)
23 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/meta_cfr/sequential_games/typing.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Typing definitions."""
16 |
17 | from typing import Any, Dict, Callable
18 | import jax.numpy as jnp
19 | import optax
20 | from open_spiel.python.examples.meta_cfr.sequential_games import game_tree_utils
21 |
22 | PyTree = Any
23 | Params = PyTree
24 | ApplyFn = Callable[..., jnp.ndarray]
25 | OptState = optax.OptState
26 |
27 | GameTree = game_tree_utils.GameTree
28 | InfostateNode = game_tree_utils.InfoState
29 | InfostateMapping = Dict[str, InfostateNode]
30 | HistoryNode = game_tree_utils.HistoryTreeNode
31 |
32 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/nfg_writer_example.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Python nfg_writer example."""
16 |
17 | from absl import app
18 | from absl import flags
19 |
20 | import pyspiel
21 |
22 | FLAGS = flags.FLAGS
23 |
24 | flags.DEFINE_string("game", "matrix_rps", "Name of the game")
25 | flags.DEFINE_string("outfile", None, "File to send the output to.")
26 |
27 |
28 | def main(_):
29 | game = pyspiel.load_game(FLAGS.game)
30 | nfg_text = pyspiel.game_to_nfg_string(game)
31 |
32 | if FLAGS.outfile is None:
33 | print(nfg_text)
34 | else:
35 | print("Exporting to {}".format(FLAGS.outfile))
36 | outfile = open(FLAGS.outfile, "w")
37 | outfile.write(nfg_text)
38 | outfile.close()
39 |
40 |
41 | if __name__ == "__main__":
42 | app.run(main)
43 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/opponent_shaping/requirements.txt:
--------------------------------------------------------------------------------
1 | wandb
2 | distrax
3 | optax
4 | dm-haiku
5 | rlax
6 | open_spiel
7 | jax
8 |
9 | # If you need cuda support, uncomment the following line. You might need change
10 | # the cuda version depending on your nvidia-driver version and you might need
11 | # to upgrade jax afterwards.
12 |
13 | # jax[cuda12] -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
14 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/rrps_poprl/README.md:
--------------------------------------------------------------------------------
1 | This code implements the PopRL algorithm described in Lanctot et al.
2 | [Population-based Evaluation in Repeated Rock-Paper-Scissors as a Benchmark for
3 | Multiagent Reinforcement Learning](https://openreview.net/forum?id=gQnJ7ODIAx)
4 |
5 | The implementation of IMPALA is an online agent version of the IMPALA example in
6 | the Haiku codebase. It has been modified to add prediction labels, which get
7 | stored in the environment.
8 |
9 | Checkpointing is not working for technical reasons (some nontrivial parts are
10 | needed to handle Haiku functions / models). It needs to be fixed if this is to
11 | run for long periods of time or in interactive mode.
12 |
13 | This implementation is NOT designed for scale.
14 |
15 | The code is provided as-is. It's a direct conversion of the code used for the
16 | paper but it has not been extensively tested after the transformation. The basic
17 | tests work and the transformation was straight-forward. However, if you run into
18 | any trouble, please contact lanctot@google.com.
19 |
--------------------------------------------------------------------------------
/open_spiel/python/examples/uniform_policy_exploitability.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Compute exploitability of a uniform policy."""
16 |
17 | from absl import app
18 | from absl import flags
19 |
20 | from open_spiel.python import policy
21 | from open_spiel.python.algorithms import exploitability
22 | import pyspiel
23 |
24 | FLAGS = flags.FLAGS
25 |
26 | flags.DEFINE_string("game", "kuhn_poker", "Name of the game")
27 |
28 |
29 | def main(_):
30 | game = pyspiel.load_game(FLAGS.game)
31 | expl = exploitability.exploitability(game, policy.UniformRandomPolicy(game))
32 | print("Exploitability: {}".format(expl))
33 |
34 |
35 | if __name__ == "__main__":
36 | app.run(main)
37 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/configs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/base_envs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/base_envs/email_plain.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """A base environment for basic emails.
16 | """
17 |
18 |
19 | from open_spiel.python.games.chat_games.envs.comm_substrates import emails
20 | from open_spiel.python.games.chat_games.envs.utils import header
21 |
22 |
23 | w_opts = (emails.W_OPTS_PREFIX +
24 | emails.PLAIN)
25 |
26 | HEADER = header.Header(emails.PLAIN,
27 | w_opts,
28 | emails.strip_msg,
29 | emails.SPECIAL_CHARS)
30 |
31 | Scenario = header.BaseScenario
32 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/comm_substrates/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/observations/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/observations/summary.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Prompts useful for inducing LLM-summarization.
16 | """
17 |
18 | from open_spiel.python.games.chat_games.envs.utils import text
19 |
20 |
21 | prefix = ('You are an assistant designed to summarize conversational ' +
22 | 'dialogue. Please take note of the most import events ' +
23 | 'in the conversation. Especially take note if the final ' +
24 | 'message includes a question. Provide your summary in 100 ' +
25 | 'words or less. Please summarize the following dialogue.')
26 | PREFIX = text.wrap([prefix])[0] + '\n\n'
27 |
28 | POSTFIX = '\n\nSummary:\n'
29 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/observations/summary_debate.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Prompts useful for inducing LLM-summarization of debates.
16 | """
17 |
18 | from open_spiel.python.games.chat_games.envs.utils import text
19 |
20 |
21 | prefix = ('You are an assistant designed to summarize the key arguments in ' +
22 | 'a debate. Please take note of the most import arguments ' +
23 | 'from each side. Provide your summary in 100 ' +
24 | 'words or less. Please summarize the following debate.')
25 | PREFIX = text.wrap([prefix])[0] + '\n\n'
26 |
27 | POSTFIX = '\n\nDebate Summary:\n'
28 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/observations/utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Utils for defining observation (feature extraction) prompts.
16 | """
17 |
18 | import dataclasses
19 |
20 | from open_spiel.python.games.chat_games.envs.observations import summary
21 |
22 |
23 | @dataclasses.dataclass(frozen=True)
24 | class Observation:
25 | obs_trans_prefix: str = summary.PREFIX
26 | obs_trans_postfix: str = summary.POSTFIX
27 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/payoffs/README.md:
--------------------------------------------------------------------------------
1 | # LLM Payoff Prompts
2 |
3 | Engineer an LLM prompt that results in an LLM outputting a payoff `$v`$ in the
4 | form of "$` v `$/MAX_PAYOFF" for a given player. The prompt must contain
5 | the formatting keyword arguments "m" (for the text message the LLM is meant to
6 | score) and "p" (for the player the LLM is providing a score for).
7 |
8 | See sentiment.py for example.
9 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/payoffs/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/payoffs/utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Utils for defining payoff prompts.
16 | """
17 |
18 | import dataclasses
19 |
20 | from open_spiel.python.games.chat_games.envs.observations import summary
21 |
22 |
23 | @dataclasses.dataclass(frozen=True)
24 | class Payoff:
25 | query: str
26 | min: int
27 | max: int
28 | obs_trans_prefix: str = summary.PREFIX
29 | obs_trans_postfix: str = summary.POSTFIX
30 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/actions/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/actions/arguments.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Examples of argument styles.
16 | """
17 |
18 | STYLES = ['logos',
19 | 'pathos',
20 | 'ethos']
21 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/actions/tones.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Examples of tones -- useful for generating additional examples.
16 | """
17 |
18 | TONES = ['kind',
19 | 'thoughtful',
20 | 'condescending',
21 | 'aggressive',
22 | 'aggreable',
23 | 'clueless',
24 | 'mean',
25 | 'rude',
26 | 'assertive']
27 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/domains/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/players/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/scenarios/players/names.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Examples of names -- useful for generating additional examples.
16 | """
17 |
18 | NAMES = ['Ian',
19 | 'Luke',
20 | 'Siqi',
21 | 'Georgios']
22 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/termination/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/termination/utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Utils for defining game (episode) termination prompts.
16 | """
17 |
18 | import dataclasses
19 |
20 | from open_spiel.python.games.chat_games.envs.observations import summary
21 |
22 |
23 | @dataclasses.dataclass(frozen=True)
24 | class Termination:
25 | query: str
26 | obs_trans_prefix: str = summary.PREFIX
27 | obs_trans_postfix: str = summary.POSTFIX
28 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/envs/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/chat_games/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/games/data.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Numerical information about some games or some specific settings of games.
16 |
17 | TODO(author2): Ideally, this should also be available from C++.
18 | """
19 |
20 | import pyspiel
21 |
22 |
23 | def kuhn_nash_equilibrium(alpha):
24 | """Returns a Nash Equilibrium in Kuhn parameterized by alpha in [0, 1/3].
25 |
26 | See https://en.wikipedia.org/wiki/Kuhn_poker#Optimal_strategy
27 |
28 | Args:
29 | alpha: The probability to bet on a Jack for Player 0.
30 |
31 | Raises:
32 | ValueError: If `alpha` is not within [0, 1/3].
33 | """
34 | if not 0 <= alpha <= 1 / 3:
35 | raise ValueError("alpha ({}) must be in [0, 1/3]".format(alpha))
36 | return pyspiel.kuhn_poker.get_optimal_policy(alpha)
37 |
--------------------------------------------------------------------------------
/open_spiel/python/jax/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/open_spiel/python/jax/cfr/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/README.md:
--------------------------------------------------------------------------------
1 | # Mean Field Games Open Spiel Python API
2 |
3 | This is a Python API for Mean Field Games in OpenSpiel.
4 |
5 | This code is experimental and we recommend you not to use it yet unless you are
6 | part of the project.
7 |
8 | The directory `python/mfg/algorithms/*` contain all algorithm implementations
9 | and `python/mfg/games/*` contains the games implementation.
10 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/algorithms/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/algorithms/pytorch/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/games/crowd_modelling_2d_test.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | """Tests for crowd_modelling_2d."""
15 |
16 | from absl.testing import absltest
17 |
18 | from open_spiel.python.mfg.games import crowd_modelling_2d
19 |
20 |
21 | class CrowdModelling2DTest(absltest.TestCase):
22 |
23 | def test_grid_to_forbidden_states(self):
24 | forbidden_states = crowd_modelling_2d.grid_to_forbidden_states([
25 | "#####",
26 | "# # #",
27 | "# #",
28 | "#####",
29 | ])
30 |
31 | self.assertEqual(
32 | forbidden_states,
33 | "[0|0;1|0;2|0;3|0;4|0;0|1;2|1;4|1;0|2;4|2;0|3;1|3;2|3;3|3;4|3]")
34 |
35 |
36 | if __name__ == "__main__":
37 | absltest.main()
38 |
--------------------------------------------------------------------------------
/open_spiel/python/mfg/utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | """MFG utilities."""
15 |
16 | import pickle
17 |
18 | from open_spiel.python.utils import gfile
19 | from open_spiel.python.mfg import distribution
20 |
21 |
22 | def save_parametric_distribution(dist: distribution.ParametricDistribution,
23 | filename: str):
24 | """Saves the parametric distribution to a Pickle file."""
25 | with gfile.Open(filename, "wb") as f:
26 | pickle.dump(dist.get_params(), f, protocol=pickle.DEFAULT_PROTOCOL)
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/algorithms_corr_dist.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_CORR_DIST_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_CORR_DIST_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for trajectories.
21 | namespace open_spiel {
22 | void init_pyspiel_algorithms_corr_dist(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_CORR_DIST_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/algorithms_trajectories.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_TRAJECTORIES_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_TRAJECTORIES_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for trajectories.
21 | namespace open_spiel {
22 | void init_pyspiel_algorithms_trajectories(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_ALGORITHMS_TRAJECTORIES_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/bots.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_BOTS_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_BOTS_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Python bindings for bots.
21 | namespace open_spiel {
22 | void init_pyspiel_bots(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_BOTS_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/evaluation_sco.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_EVALUATION_SCO_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_EVALUATION_SCO_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_evaluation_sco(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_EVALUATION_SCO_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/game_transforms.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_GAME_TRANSFORMS_PYSPIEL_H_
16 | #define OPEN_SPIEL_GAME_TRANSFORMS_PYSPIEL_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for game transforms.
21 | namespace open_spiel {
22 | void init_pyspiel_game_transforms(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_GAME_TRANSFORMS_PYSPIEL_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_backgammon.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BACKGAMMON_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BACKGAMMON_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_backgammon(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BACKGAMMON_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_bargaining.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BARGAINING_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BARGAINING_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/bargaining.
21 | namespace open_spiel {
22 | void init_pyspiel_games_bargaining(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BARGAINING_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_blackjack.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BLACKJACK_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BLACKJACK_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for blackjack.
21 | namespace open_spiel {
22 | void init_pyspiel_games_blackjack(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BLACKJACK_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_bridge.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BRIDGE_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BRIDGE_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for bridge.
21 | namespace open_spiel {
22 | void init_pyspiel_games_bridge(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BRIDGE_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_chess.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_CHESS_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_CHESS_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_chess(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_CHESS_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_colored_trails.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_COLORED_TRAILS_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_COLORED_TRAILS_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_colored_trails(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_BARGAINING_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_dots_and_boxes.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_DOTS_AND_BOXES_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_DOTS_AND_BOXES_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_dots_and_boxes(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_DOTS_AND_BOXES_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_euchre.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_EUCHRE_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_EUCHRE_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for euchre.
21 | namespace open_spiel {
22 | void init_pyspiel_games_euchre(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_EUCHRE_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_gin_rummy.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_GIN_RUMMY_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_GIN_RUMMY_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for gin_rummy.
21 | namespace open_spiel {
22 | void init_pyspiel_games_gin_rummy(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_GIN_RUMMY_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_kuhn_poker.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/python/pybind11/games_kuhn_poker.h"
16 |
17 | #include "open_spiel/games/kuhn_poker/kuhn_poker.h"
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | namespace py = ::pybind11;
21 |
22 | void open_spiel::init_pyspiel_games_kuhn_poker(py::module& m) {
23 | py::module sub = m.def_submodule("kuhn_poker");
24 | sub.def("get_optimal_policy", &kuhn_poker::GetOptimalPolicy);
25 | }
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_kuhn_poker.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_KUHN_POKER_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_KUHN_POKER_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_kuhn_poker(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_KUHN_POKER_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_leduc_poker.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_LEDUC_POKER_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_LEDUC_POKER_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_leduc_poker(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_LEDUC_POKER_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_negotiation.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_NEGOTIATION_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_NEGOTIATION_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_negotiation(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_NEGOTIATION_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_spades.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_SPADES_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_SPADES_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for spades.
21 | namespace open_spiel {
22 | void init_pyspiel_games_spades(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_SPADES_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_tarok.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TAROK_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TAROK_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | namespace open_spiel {
21 |
22 | void init_pyspiel_games_tarok(::pybind11::module& m);
23 |
24 | } // namespace open_spiel
25 |
26 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TAROK_H_
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_tic_tac_toe.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TIC_TAC_TOE_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TIC_TAC_TOE_H_
17 | #include "open_spiel/python/pybind11/pybind11.h"
18 |
19 | // Initialize the Python interface for games/tic_tac_toe.
20 | namespace open_spiel {
21 |
22 | void init_pyspiel_games_tic_tac_toe(::pybind11::module &m);
23 |
24 | } // namespace open_spiel
25 |
26 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TIC_TAC_TOE_H_
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_tiny_bridge.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TINY_BRIDGE_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TINY_BRIDGE_H_
17 | #include "open_spiel/python/pybind11/pybind11.h"
18 |
19 | namespace open_spiel {
20 |
21 | void init_pyspiel_games_tiny_bridge(::pybind11::module& m);
22 |
23 | } // namespace open_spiel
24 |
25 |
26 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TINY_BRIDGE_H_
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_trade_comm.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 |
16 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TRADE_COMM_H_
17 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TRADE_COMM_H_
18 |
19 | #include "open_spiel/python/pybind11/pybind11.h"
20 |
21 | namespace open_spiel {
22 |
23 | void init_pyspiel_games_trade_comm(::pybind11::module& m);
24 |
25 | } // namespace open_spiel
26 |
27 |
28 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_TRADE_COMM_H_
29 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_universal_poker.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/python/pybind11/games_universal_poker.h"
16 |
17 | #include "open_spiel/games/universal_poker/universal_poker.h"
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | namespace py = ::pybind11;
21 |
22 | void open_spiel::init_pyspiel_games_universal_poker(py::module& m) {
23 | py::module sub = m.def_submodule("universal_poker");
24 | sub.def("load_universal_poker_from_acpc_gamedef",
25 | &universal_poker::LoadUniversalPokerGameFromACPCGamedef);
26 | }
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/games_universal_poker.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_GAMES_UNIVERSAL_POKER_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_GAMES_UNIVERSAL_POKER_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialize the Python interface for games/negotiation.
21 | namespace open_spiel {
22 | void init_pyspiel_games_universal_poker(::pybind11::module &m);
23 | void init_pyspiel_games_kuhn_poker(::pybind11::module &m);
24 | }
25 |
26 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_GAMES_UNIVERSAL_POKER_H_
27 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/observer.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_OBSERVER_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_OBSERVER_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Initialze the Python interface for observers.
21 | namespace open_spiel {
22 | void init_pyspiel_observer(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_OBSERVER_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/policy.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_POLICY_H_
16 | #define OPEN_SPIEL_PYTHON_PYBIND11_POLICY_H_
17 |
18 | #include "open_spiel/python/pybind11/pybind11.h"
19 |
20 | // Python bindings for policies and algorithms handling them.
21 | namespace open_spiel {
22 | void init_pyspiel_policy(::pybind11::module &m);
23 | }
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_POLICY_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pybind11/utils.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | #ifndef OPEN_SPIEL_PYTHON_PYBIND11_UTILS_H_
15 | #define OPEN_SPIEL_PYTHON_PYBIND11_UTILS_H_
16 |
17 | #include "open_spiel/python/pybind11/pybind11.h"
18 |
19 | namespace open_spiel {
20 |
21 | void init_pyspiel_utils(::pybind11::module& m);
22 |
23 | } // namespace open_spiel
24 |
25 | #endif // OPEN_SPIEL_PYTHON_PYBIND11_UTILS_H_
26 |
--------------------------------------------------------------------------------
/open_spiel/python/pytorch/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
16 |
--------------------------------------------------------------------------------
/open_spiel/python/pytorch/losses/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/test_utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Useful functions for testing."""
16 |
17 | from typing import Optional
18 | import numpy as np
19 | import pyspiel
20 |
21 |
22 | def random_playout(state: pyspiel.State, seed: Optional[int] = None):
23 | """Plays random actions until the state is terminal."""
24 | rng = np.random.RandomState(seed)
25 | while not state.is_terminal():
26 | state.apply_action(rng.choice(state.legal_actions()))
27 | return state
28 |
--------------------------------------------------------------------------------
/open_spiel/python/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/tests/mfg_implementation_test/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/utils/app.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Entry point for applications with platform specific initializations."""
16 |
17 | from absl.app import * # pylint: disable=wildcard-import
18 |
--------------------------------------------------------------------------------
/open_spiel/python/utils/file_utils.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """File utilities."""
16 |
17 | import os
18 |
19 |
20 | def find_file(filename, levels):
21 | if os.path.isfile(filename):
22 | return filename
23 | else:
24 | for _ in range(levels):
25 | filename = '../' + filename
26 | if os.path.isfile(filename):
27 | return filename
28 | return None
29 |
30 |
--------------------------------------------------------------------------------
/open_spiel/python/utils/gfile.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """This is replaces google's gfile used for network storage.
16 |
17 | A more complete public version of gfile:
18 | https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/platform/gfile.py
19 | """
20 |
21 | import os
22 |
23 | # pylint: disable=invalid-name
24 | Exists = os.path.exists
25 | IsDirectory = os.path.isdir
26 | ListDir = os.listdir
27 | MakeDirs = os.makedirs
28 | Open = open
29 |
--------------------------------------------------------------------------------
/open_spiel/python/utils/shared_value.py:
--------------------------------------------------------------------------------
1 | # Copyright 2022 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """A shared value without deep copy."""
16 |
17 |
18 | class SharedValue(object):
19 | """A shared value without deep copy."""
20 |
21 | def __init__(self, value):
22 | self.value = value
23 |
24 | def __deepcopy__(self, memo):
25 | return SharedValue(self.value)
26 |
--------------------------------------------------------------------------------
/open_spiel/python/visualizations/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/voting/README.md:
--------------------------------------------------------------------------------
1 |
2 | A general implementation of voting rules from computational social choice.
3 |
4 | This code implements the voting rules in Voting as Evaluation (VasE): Lanctot et
5 | al.
6 | [Evaluating Agents using Social Choice Theory](https://arxiv.org/abs/2312.03121).
7 |
8 | It also includes a few example uses of running VasE on the Atari datasets
9 | referenced in the paper.
10 |
11 |
--------------------------------------------------------------------------------
/open_spiel/python/voting/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 |
--------------------------------------------------------------------------------
/open_spiel/python/voting/examples/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 DeepMind Technologies Limited
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
--------------------------------------------------------------------------------
/open_spiel/rust/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(RUST_BINDINGS ${RUST_BINDINGS}
2 | src/rust_open_spiel.cc
3 | src/rust_open_spiel.h
4 | )
5 |
6 | set(RUST_API_FILES
7 | Cargo.toml
8 | build.rs
9 | src/rust_open_spiel.rs
10 | src/example.rs
11 | )
12 |
13 | # Note: needs to be SHARED rather than MODULE to work on MacOS
14 | add_library(rust_spiel SHARED ${RUST_BINDINGS} ${OPEN_SPIEL_OBJECTS})
15 |
16 | # Copy the files keeping the directories intact
17 | foreach(rust_api_file IN LISTS RUST_API_FILES)
18 | get_filename_component(file_dir ${rust_api_file} DIRECTORY)
19 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${file_dir})
20 | file(COPY ${rust_api_file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${file_dir})
21 | endforeach(rust_api_file)
22 |
23 | add_custom_target(rust_bindgen ALL $ENV{HOME}/.cargo/bin/bindgen ${CMAKE_CURRENT_SOURCE_DIR}/src/rust_open_spiel.h -o ${CMAKE_CURRENT_BINARY_DIR}/src/open_spiel_bindings.rs
24 | DEPENDS rust_spiel)
25 |
26 | add_custom_target(rust_open_spiel ALL cargo build
27 | DEPENDS rust_spiel rust_bindgen
28 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
29 |
30 | add_test(NAME rust_example_test COMMAND cargo run --example example)
31 | set_property(TEST rust_example_test
32 | PROPERTY ENVIRONMENT
33 | LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR};
34 | TEST_SRCDIR=${CMAKE_CURRENT_BINARY_DIR})
35 |
--------------------------------------------------------------------------------
/open_spiel/rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "libopen_spiel-sys"
3 | version = "1.0.2"
4 | links = "rust_spiel"
5 | build = "build.rs"
6 | edition = "2018"
7 | crate_type = "lib"
8 |
9 | [dependencies]
10 | libc = "0.2"
11 |
12 | [lib]
13 | name = "rust_open_spiel"
14 | path = "src/rust_open_spiel.rs"
15 | test = false
16 | bench = false
17 |
18 | [[example]]
19 | name = "example"
20 | path = "src/example.rs"
21 | test = false
22 | bench = false
23 |
24 | [build-dependencies]
25 | cc = { version = "1.0", features = ["parallel"] }
26 | pkg-config = "0.3"
27 |
--------------------------------------------------------------------------------
/open_spiel/rust/README.md:
--------------------------------------------------------------------------------
1 | # OpenSpiel Rust API
2 |
3 | *Note:* This API is no longer maintained.
4 |
5 | This is a basic [Rust](https://www.rust-lang.org/) API for OpenSpiel. Please
6 | note that it is currently experimental and may not work as expected. If you use
7 | it, please report any issues. Fixes and improvements are more than welcome!
8 |
9 | See the `CMakeLists.txt` to see how it is setup: a dynamic shared library is
10 | created similarly to python extension (`librust_spiel.so`). A simple rust crate
11 | is created in this directory using `cargo build` and a simple example is run
12 | using cargo as well. Note that currently `LD_LIBRARY_PATH` must include the
13 | location of the dynamic library so that it gets properly loaded at run time.
14 |
15 | Note: this API currently only supports turn-based games. To support
16 | simultaneous-move games, several API functions would need to be added, such as
17 | legal actions for specific players, observation and information state tensors
18 | for specific players, and apply action for joint actions.
19 |
--------------------------------------------------------------------------------
/open_spiel/rust/build.rs:
--------------------------------------------------------------------------------
1 | use std::env;
2 |
3 | fn main() {
4 | let cwd = env::current_dir().unwrap();
5 | let path_str = cwd.into_os_string().into_string().unwrap();
6 | println!("cargo:rustc-link-search={}", path_str);
7 | println!("cargo:rustc-link-lib=dylib=rust_spiel");
8 | }
9 |
--------------------------------------------------------------------------------
/open_spiel/scripts/ci_python_prechecks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Only use for Github Actions CI!
18 | OS=`uname -a | awk '{print $1}'`
19 | if [[ "$OS" = "Darwin" ]]; then
20 | # This seems to be necessary to install python via brew in Github Actions
21 | rm -f /usr/local/bin/2to3-${OS_PYTHON_VERSION}
22 | rm -f /usr/local/bin/idle${OS_PYTHON_VERSION}
23 | rm -f /usr/local/bin/pydoc${OS_PYTHON_VERSION}
24 | rm -f /usr/local/bin/python${OS_PYTHON_VERSION}
25 | rm -f /usr/local/bin/python${OS_PYTHON_VERSION}*
26 | fi
27 |
28 |
--------------------------------------------------------------------------------
/open_spiel/scripts/find_jax.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | read -r -d '' TESTSCRIPT << EOT
18 | import jax
19 | import jaxlib
20 | import haiku
21 | import chex
22 | import optax
23 | print(jax.__version__)
24 | EOT
25 |
26 | PY_EXEC=$(which $1)
27 | if [[ ! -x $PY_EXEC ]]
28 | then
29 | echo "Python executable: $PY_EXEC not found or not executable."
30 | exit -1
31 | fi
32 |
33 | echo "$TESTSCRIPT" | $PY_EXEC
34 | exit $?
35 |
--------------------------------------------------------------------------------
/open_spiel/scripts/find_pytorch.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | read -r -d '' TESTSCRIPT << EOT
18 | import torch
19 | print(torch.__version__)
20 | EOT
21 |
22 | PY_EXEC=$(which $1)
23 | if [[ ! -x $PY_EXEC ]]
24 | then
25 | echo "Python executable: $PY_EXEC not found or not executable."
26 | exit -1
27 | fi
28 |
29 | echo "$TESTSCRIPT" | $PY_EXEC
30 | exit $?
31 |
--------------------------------------------------------------------------------
/open_spiel/scripts/find_tensorflow.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | read -r -d '' TESTSCRIPT << EOT
18 | import tensorflow as tf
19 | print(tf.__version__)
20 | EOT
21 |
22 | PY_EXEC=$(which $1)
23 | if [[ ! -x $PY_EXEC ]]
24 | then
25 | echo "Python executable: $PY_EXEC not found or not executable."
26 | exit -1
27 | fi
28 |
29 | echo "$TESTSCRIPT" | $PY_EXEC
30 | exit $?
31 |
--------------------------------------------------------------------------------
/open_spiel/scripts/generate_new_playthrough.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Generates a playthrough for a new game with optional parameters.
18 | # This script exists mainly as a reminder for the command to run.
19 |
20 | GAME="$1"
21 | shift
22 |
23 | if [ "$GAME" = "" ]
24 | then
25 | echo "Usage: generate_new_playthrough GAME"
26 | exit
27 | fi
28 |
29 | python open_spiel/python/examples/playthrough.py \
30 | --game $GAME \
31 | --output_file open_spiel/integration_tests/playthroughs/$GAME.txt \
32 | --alsologtostdout
33 |
--------------------------------------------------------------------------------
/open_spiel/scripts/regenerate_playthroughs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2019 DeepMind Technologies Ltd. All rights reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | # Regenerates playthroughs for all the existing playthroughs.
18 | # Run this from open_spiel/ (scripts/regenerate_playthroughs.sh) whenever
19 | # a change is made to the public API.
20 |
21 | python3 python/examples/playthrough.py \
22 | --update_path integration_tests/playthroughs
23 |
--------------------------------------------------------------------------------
/open_spiel/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library (tests OBJECT
2 | basic_tests.h
3 | basic_tests.cc
4 | console_play_test.h
5 | console_play_test.cc
6 | )
7 | target_include_directories (tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
8 |
9 | add_executable(spiel_test spiel_test.cc
10 | $ ${OPEN_SPIEL_OBJECTS})
11 | add_test(spiel_test spiel_test)
12 |
13 | add_executable(action_view_test action_view_test.cc ${OPEN_SPIEL_OBJECTS}
14 | $)
15 | add_test(action_view_test action_view_test)
16 |
17 | if (BUILD_SHARED_LIB)
18 | if (WIN32)
19 | add_executable(shared_lib_test shared_lib_test.cc ${OPEN_SPIEL_OBJECTS})
20 | else()
21 | add_executable(shared_lib_test shared_lib_test.cc)
22 | endif()
23 | target_link_libraries(shared_lib_test open_spiel)
24 | add_test(shared_lib_test shared_lib_test)
25 | endif()
26 |
--------------------------------------------------------------------------------
/open_spiel/utils/functional_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/utils/functional.h"
16 | #include "open_spiel/spiel_utils.h"
17 |
18 | namespace open_spiel {
19 | namespace {
20 |
21 | void TestZip() {
22 | std::vector actions = {1, 2, 3};
23 | std::vector probs = {0.1, 0.2, 0.3};
24 | std::vector> action_probs;
25 | Zip(actions.begin(), actions.end(), probs.begin(), action_probs);
26 |
27 | std::vector> expected_action_probs = {
28 | {1, 0.1}, {2, 0.2}, {3, 0.3}};
29 | SPIEL_CHECK_EQ(action_probs, expected_action_probs);
30 | }
31 |
32 | } // namespace
33 | } // namespace open_spiel
34 |
35 | int main(int argc, char** argv) {
36 | open_spiel::TestZip();
37 | }
38 |
--------------------------------------------------------------------------------
/open_spiel/utils/init.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/utils/init.h"
16 |
17 |
18 | namespace open_spiel {
19 |
20 | void Init(const char* usage, int* argc, char*** argv, bool remove_flags) {
21 | }
22 |
23 | } // namespace open_spiel
24 |
--------------------------------------------------------------------------------
/open_spiel/utils/init.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_UTILS_INIT_H_
16 | #define OPEN_SPIEL_UTILS_INIT_H_
17 |
18 | namespace open_spiel {
19 |
20 | // A utility function useful for mixing internal and external use of OpenSpiel.
21 | // Intended to be called early in a program's main. Currently only necessary
22 | // in programs that mix internal and external use (e.g. utils/file.h).
23 | void Init(const char* usage, int* argc, char*** argv, bool remove_flags);
24 |
25 | } // namespace open_spiel
26 |
27 | #endif // OPEN_SPIEL_UTILS_INIT_H_
28 |
--------------------------------------------------------------------------------
/open_spiel/utils/random.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 |
16 | #include "open_spiel/utils/random.h"
17 |
18 | namespace open_spiel {
19 |
20 | namespace {
21 | std::uniform_real_distribution uniformDist;
22 | } // namespace
23 |
24 | double RandomMT::RandomUniform() { return uniformDist(generator_); }
25 |
26 | double RandomFixedSequence::RandomUniform() {
27 | double v = values_[position_];
28 | if (++position_ == values_.size()) position_ = 0;
29 | return v;
30 | }
31 |
32 | } // namespace open_spiel
33 |
--------------------------------------------------------------------------------
/open_spiel/utils/thread.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/utils/thread.h"
16 |
17 | #include // NOLINT
18 |
19 | namespace open_spiel {
20 |
21 | class Thread::ThreadImpl : public std::thread {
22 | public:
23 | using std::thread::thread; // Inherit the constructors.
24 | };
25 |
26 | Thread::Thread(std::function fn) : thread_(new ThreadImpl(fn)) {}
27 |
28 | // defaults required to be here for pimpl to work.
29 | Thread::~Thread() = default;
30 | Thread::Thread(Thread&& other) = default;
31 | Thread& Thread::operator=(Thread&& other) = default;
32 |
33 | void Thread::join() { thread_->join(); }
34 |
35 | } // namespace open_spiel
36 |
--------------------------------------------------------------------------------
/open_spiel/utils/usage_logging.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "open_spiel/utils/usage_logging.h"
16 |
17 |
18 | namespace open_spiel {
19 |
20 | void LogUsage() {
21 | }
22 |
23 | } // namespace open_spiel
24 |
--------------------------------------------------------------------------------
/open_spiel/utils/usage_logging.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 DeepMind Technologies Limited
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef OPEN_SPIEL_UTILS_USAGE_LOGGING_H_
16 | #define OPEN_SPIEL_UTILS_USAGE_LOGGING_H_
17 |
18 | namespace open_spiel {
19 |
20 | // Record OpenSpiel usage. No-op for external users and is called upon creation
21 | // of an OpenSpiel game.
22 | void LogUsage();
23 |
24 | } // namespace open_spiel
25 |
26 | #endif // OPEN_SPIEL_UTILS_USAGE_LOGGING_H_
27 |
--------------------------------------------------------------------------------
/readthedocs.yml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | # Build documentation in the docs/ directory with Sphinx
9 | sphinx:
10 | configuration: docs/conf.py
11 |
12 | # Optionally build your docs in additional formats such as PDF and ePub
13 | formats: all
14 |
15 | # Optionally set the version of Python and requirements required to build your docs
16 | python:
17 | install:
18 | - requirements: docs/requirements.readthedocs.txt
19 |
20 | build:
21 | os: ubuntu-20.04
22 | tools:
23 | python: "3.8"
24 | jobs:
25 | pre_build:
26 | - echo "Running pre-build commands."
27 | - echo `date`
28 | - echo `pwd`
29 | - echo `ls`
30 | - echo `ls docs`
31 | - echo "Fixing the table links"
32 | - bash docs/fix_table_links.sh
33 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | # The core OpenSpiel pip dependencies.
2 | #
3 | # Note that there are optional python packages used by some of the python
4 | # algorithms or tools in OpenSpiel that are purposely excluded (e.g.,
5 | # cvxopt, nashpy, matplotlib, etc.) This is because we want to keep only
6 | # the dependencies that are absolutely necessary to use the Python API.
7 | #
8 | # However, when testing using continuous integration like GitHub Actions,
9 | # we install several more packages to ensure the proper tests are
10 | # included. See open_spiel/scripts/python_extra_deps.sh for the extra
11 | # packages and their versions we use for testing purposes.
12 | pip >= 20.0.2
13 | attrs >= 19.3.0
14 | absl-py >= 0.10.0
15 | numpy >= 1.21.5
16 | scipy >= 1.10.1
17 | ml-collections >= 0.1.1
18 |
--------------------------------------------------------------------------------