예제 #1
0
def main(argv):
  del argv

  game = pyspiel.load_game(FLAGS.game)
  game_type = game.get_type()

  if game_type.dynamics == pyspiel.GameType.Dynamics.SIMULTANEOUS:
    logging.warn("%s is not turn-based. Trying to reload game as turn-based.",
                 FLAGS.game)
    game = pyspiel.load_game_as_turn_based(FLAGS.game)

  gametree = export_gambit(game)  # use default decorators
  if FLAGS.print:
    print(gametree)
  else:
    with open(FLAGS.out, "w") as f:
      f.write(gametree)
    logging.info("Game tree for %s saved to file: %s", FLAGS.game, FLAGS.out)
예제 #2
0
    def test_gambit_export_can_be_imported(self):
        game_list = [
            "kuhn_poker",
            "kuhn_poker(players=3)",
        ]
        for game_name in game_list:
            game_orig = pyspiel.load_game(game_name)
            gbt = export_gambit(game_orig)
            f = tempfile.NamedTemporaryFile("w", delete=False)
            f.write(gbt)
            f.flush()
            game_efg = pyspiel.load_game("efg_game(filename=%s)" % f.name)
            f.close()

            self._infoset_table_orig = collections.defaultdict(lambda: [])
            self._infoset_table_efg = collections.defaultdict(lambda: [])
            self._recursive_check(game_orig.new_initial_state(),
                                  game_efg.new_initial_state())

            self._check_infoset_isomorphism(self._infoset_table_orig,
                                            self._infoset_table_efg)