diff --git a/notes.md b/notes.md index 490d40c..e333a6b 100644 --- a/notes.md +++ b/notes.md @@ -45,9 +45,17 @@ and it's your turn, which action would you take? Why? ---+---+--- ---+---+--- ---+---+--- ---+---+--- | | | | O | | | | -### Initial game state +In the first state shown, I would put an X in spot 5 to get a winning combo. +In the second state shown, I would put an X in spot 5 to prevent 0 from winning next turn. +In the third state shown, I would put an X in spot 0 because it will make it possible to get a winning combo on X's next turn regardless of where O plays. +In the fourth state shown, I would put an X in spot 4 to have more possible ways to win. Half of the winning combos contain spot 4. +### Initial game state You can get the inital game state using game.get_initial_state(). What is the current and future reward for this state? What does this mean? +The current and future reward for state = {"board": ['-','O','O','X','X','-','-','-','-'], "player_x": True} is 1. This means that X will win. X can play spot 5 and win. +The initial state is: +{'board': ['-', '-', '-', '-', '-', '-', '-', '-', '-'], 'player_x': True} +For the initial state, the current and future reward is 0. That means it is equally likely for either player to win or lose. \ No newline at end of file diff --git a/play_ttt.py b/play_ttt.py index ef5530a..ca62da9 100644 --- a/play_ttt.py +++ b/play_ttt.py @@ -3,7 +3,7 @@ from ttt.view import TTTView from ttt.player import TTTHumanPlayer, TTTComputerPlayer player0 = TTTHumanPlayer("Player 1") -player1 = TTTHumanPlayer("Player 2") +player1 = TTTComputerPlayer("Computer") game = TTTGame() view = TTTView(player0, player1) diff --git a/ttt/player.py b/ttt/player.py index bfbbe15..0349fdf 100644 --- a/ttt/player.py +++ b/ttt/player.py @@ -1,5 +1,6 @@ from click import Choice, prompt from strategy.random_strategy import RandomStrategy +from strategy.lookahead_strategy import LookaheadStrategy from ttt.game import TTTGame import random @@ -24,7 +25,7 @@ class TTTComputerPlayer: def __init__(self, name): "Sets up the player." self.name = name - self.strategy = RandomStrategy(TTTGame()) + self.strategy = LookaheadStrategy(TTTGame(), deterministic=False) def choose_action(self, state): "Chooses a random move from the moves available."