示例#1
0
def main(_):
    game = pyspiel.load_game(
        FLAGS.game,
        {"players": FLAGS.players},
    )

    if FLAGS.sampling == "external":
        solver = pyspiel.ExternalSamplingMCCFRSolver(
            game,
            avg_type=pyspiel.MCCFRAverageType.FULL,
        )
    elif FLAGS.sampling == "outcome":
        solver = pyspiel.OutcomeSamplingMCCFRSolver(game)

    run_iterations(game, solver)

    print("Persisting the model...")
    with open(MODEL_FILE_NAME.format(FLAGS.sampling), "wb") as file:
        pickle.dump(solver, file, pickle.HIGHEST_PROTOCOL)

    print("Loading the model...")
    with open(MODEL_FILE_NAME.format(FLAGS.sampling), "rb") as file:
        loaded_solver = pickle.load(file)
    print("Exploitability of the loaded model: {:.6f}".format(
        pyspiel.exploitability(game, loaded_solver.average_policy())))

    run_iterations(game, solver, start_iteration=int(FLAGS.iterations / 2))
示例#2
0
def main(_):
  game = pyspiel.load_game(
      FLAGS.game,
      {"players": pyspiel.GameParameter(FLAGS.players)},
  )

  if FLAGS.sampling == "external":
    solver = pyspiel.ExternalSamplingMCCFRSolver(
        game,
        avg_type=pyspiel.MCCFRAverageType.FULL,
    )
  elif FLAGS.sampling == "outcome":
    solver = pyspiel.OutcomeSamplingMCCFRSolver(game)

  for i in range(FLAGS.iterations):
    solver.run_iteration()
    print("Iteration {} exploitability: {:.6f}".format(
        i, pyspiel.exploitability(game, solver.average_policy())))