ttt.cli package

Submodules

ttt.cli.cpu_vs_cpu module

ttt.cli.cpu_vs_cpu.main()[source]
ttt.cli.cpu_vs_cpu.play_cpu_vs_cpu(cpu_1_weights_path: str, cpu_1_mode: str, cpu_2_weights_path: str, cpu_2_mode: str, num_rounds: int, display_board: bool = True, display_text: bool = True) → None[source]

Plays a game between two cpu players.

Parameters
  • cpu_1_weights_path (str) – Path to the JSON file with the first player’s weights

  • cpu_1_mode (str) – Player 1 policy. Whether best or random.

  • cpu_2_weights_path (str) – Path to the JSON file with the second player’s weights

  • cpu_2_mode (str) – Player 1 policy. Whether best or random.

  • num_rounds (int) – Number or rounds to be played.

  • display_board (bool) – Whether to display the board after each move.

  • display_text (bool) – Whether to display game information

ttt.cli.human_vs_cpu module

ttt.cli.human_vs_cpu.main()[source]
ttt.cli.human_vs_cpu.play_human_vs_cpu(cpu_weights_path: str, cpu_mode: str) → None[source]

Plays a game between a human player and a CPU agent.

Parameters
  • cpu_weights_path (str) – Path to the JSON file with the first player’s weights

  • cpu_mode (str) – Player 1 policy. Whether best or random.

ttt.cli.human_vs_human module

ttt.cli.human_vs_human.main()[source]
ttt.cli.human_vs_human.play_human_vs_player() → None[source]

Plays a game between 2 human players

ttt.cli.train module

ttt.cli.train.main()[source]
ttt.cli.train.train_agent(output_path: str, lr: float = 0.1, exploration_iterations: int = 2500, exploitation_iterations: int = 1500, exploration_exploitation_iterations: int = 1000) → None[source]

Trains a new agent.

Parameters
  • output_path (str) – Where to save agent’s weights. E.g., weights.json.

  • lr (float) – Learning rate.

  • exploration_iterations (int) – Number of iterations during exploration phase.

  • exploitation_iterations (int) – Number of iterations during exploitation phase.

  • exploration_exploitation_iterations (int) – Number of iterations during exploration-exploitation phase.