def test_efg_game(self): game = pyspiel.load_efg_game(pyspiel.get_sample_efg_data()) # EFG games loaded directly by string cannot serialize because the game's # data cannot be passed in via string parameter. for _ in range(0, 100): self.sim_game( game, check_pyspiel_serialization=False, check_pickle_serialization=False) game = pyspiel.load_efg_game(pyspiel.get_kuhn_poker_efg_data()) for _ in range(0, 100): self.sim_game( game, check_pyspiel_serialization=False, check_pickle_serialization=False) # EFG games loaded by file should serialize properly: filename = file_utils.find_file( "open_spiel/games/efg/sample.efg", 2) if filename is not None: game = pyspiel.load_game("efg_game(filename=" + filename + ")") for _ in range(0, 100): self.sim_game(game) filename = file_utils.find_file( "open_spiel/games/efg/sample.efg", 2) if filename is not None: game = pyspiel.load_game("efg_game(filename=" + filename + ")") for _ in range(0, 100): self.sim_game(game)
def test_simple_game(self): game = pyspiel.load_efg_game(SIMPLE_EFG_DATA) env = rl_environment.Environment(game=game) with self.session() as sess: agent = dqn.DQN(sess, 0, state_representation_size=game. information_state_tensor_shape()[0], num_actions=game.num_distinct_actions(), hidden_layers_sizes=[16], replay_buffer_capacity=100, batch_size=5, epsilon_start=0.02, epsilon_end=0.01) total_reward = 0 sess.run(tf.global_variables_initializer()) for _ in range(100): time_step = env.reset() while not time_step.last(): agent_output = agent.step(time_step) time_step = env.step([agent_output.action]) total_reward += time_step.rewards[0] agent.step(time_step) self.assertGreaterEqual(total_reward, 75)
def test_kuhn_poker_efg(self): game = pyspiel.load_efg_game(pyspiel.get_kuhn_poker_efg_data()) val1, val2, _, _ = sequence_form_lp.solve_zero_sum_game(game) # value from Kuhn 1950 or https://en.wikipedia.org/wiki/Kuhn_poker self.assertAlmostEqual(val1, -1 / 18) self.assertAlmostEqual(val2, +1 / 18)