from drl_gym.agents import CommandLineAgent, RandomAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_to_the_end if __name__ == "__main__": gs = TicTacToeGameState() agent0 = CommandLineAgent() agent1 = RandomAgent() print(gs) run_to_the_end([agent0, agent1], gs) print(gs)
from drl_gym.agents import RandomAgent, HalfAlphaZeroAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_for_n_games_and_print_stats if __name__ == "__main__": import tensorflow as tf tf.compat.v1.disable_eager_execution() gs = TicTacToeGameState() agent0 = HalfAlphaZeroAgent(10, gs.get_action_space_size(), keep_memory=True) agent1 = RandomAgent() for _ in range(1000): run_for_n_games_and_print_stats([agent0, agent1], gs, 100, shuffle_players=True)
from drl_gym.agents import TabQLearningAgent, CommandLineAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_for_n_games_and_print_stats, run_step if __name__ == "__main__": gs = TicTacToeGameState() agent0 = TabQLearningAgent() agent1 = TabQLearningAgent() agent0.alpha = 0.1 agent0.epsilon = 0.005 agent1.alpha = 0.1 agent1.epsilon = 0.005 for _ in range(100): run_for_n_games_and_print_stats([agent0, agent1], gs, 5000) agent0.epsilon = -1.0 agent1.epsilon = -1.0 run_for_n_games_and_print_stats([agent0, agent1], gs, 100) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([agent0, CommandLineAgent()], gs_clone) print(gs_clone) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([CommandLineAgent(), agent1], gs_clone) print(gs_clone)
from drl_gym.agents import CommandLineAgent, PPOAgent, RandomAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_for_n_games_and_print_stats, run_step if __name__ == "__main__": gs = TicTacToeGameState() agent0 = PPOAgent( state_space_size=gs.get_vectorized_state().shape[0], action_space_size=gs.get_action_space_size(), ) agent1 = RandomAgent() for i in range(100): run_for_n_games_and_print_stats([agent0, agent1], gs, 5000) run_for_n_games_and_print_stats([agent0, agent1], gs, 100) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([agent0, CommandLineAgent()], gs_clone) print(gs_clone) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([CommandLineAgent(), agent1], gs_clone) print(gs_clone)
from drl_gym.agents import CommandLineAgent, DeepQLearningAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_for_n_games_and_print_stats, run_step if __name__ == "__main__": gs = TicTacToeGameState() agent0 = DeepQLearningAgent(action_space_size=gs.get_action_space_size()) agent1 = DeepQLearningAgent(action_space_size=gs.get_action_space_size()) agent0.alpha = 0.1 agent0.epsilon = 0.005 agent1.alpha = 0.1 agent1.epsilon = 0.005 for i in range(100): run_for_n_games_and_print_stats([agent0, agent1], gs, 5000) agent0.epsilon = -1.0 agent1.epsilon = -1.0 run_for_n_games_and_print_stats([agent0, agent1], gs, 100) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([agent0, CommandLineAgent()], gs_clone) print(gs_clone) gs_clone = gs.clone() while not gs_clone.is_game_over(): run_step([CommandLineAgent(), agent1], gs_clone) print(gs_clone)
from drl_gym.agents import RandomAgent, ExpertApprenticeAgent from drl_gym.environments.tictactoe import TicTacToeGameState from drl_gym.runners import run_for_n_games_and_print_stats if __name__ == "__main__": import tensorflow as tf tf.compat.v1.disable_eager_execution() gs = TicTacToeGameState() agent0 = ExpertApprenticeAgent(100, gs.get_action_space_size()) agent1 = RandomAgent() for _ in range(1000): run_for_n_games_and_print_stats([agent0, agent1], gs, 1000)