From 0a3d7e31f57451b2ebda237163f4140f245aa2d2 Mon Sep 17 00:00:00 2001 From: Cory Date: Wed, 20 Mar 2024 20:13:39 -0400 Subject: [PATCH] Completed checkpoint 3 What I changed (I gave the computer player the look ahead strategy. This also required importing LookaheadStrategy in player.py. I also answered the questions in notes.md.) Why I changed it (I was working on completing checkpoint 3. I realized I had to do the importing since otherwise it wouldn't let me play.) Estimate for remaining time to finish assignment: [I am REALLY bad at these estimates. I mean in terms of actual work time, I'm probably not too far off. Fingers crossed, maybe another hour of actual work time?] --- notes.md | 1 + play_ttt.py | 4 ++-- ttt/player.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/notes.md b/notes.md index 75c8ae2..22fac4f 100644 --- a/notes.md +++ b/notes.md @@ -37,4 +37,5 @@ For the first one, I would put an X on the rightmost cell in the middle row. Thi 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 this state is 1. This means the state favors player X assuming both players continue using the same look ahead strategy. diff --git a/play_ttt.py b/play_ttt.py index ef5530a..1b78ace 100644 --- a/play_ttt.py +++ b/play_ttt.py @@ -2,8 +2,8 @@ from ttt.game import TTTGame from ttt.view import TTTView from ttt.player import TTTHumanPlayer, TTTComputerPlayer -player0 = TTTHumanPlayer("Player 1") -player1 = TTTHumanPlayer("Player 2") +player0 = TTTHumanPlayer("Pleayer 1") +player1 = TTTComputerPlayer("Robot 1") game = TTTGame() view = TTTView(player0, player1) diff --git a/ttt/player.py b/ttt/player.py index bfbbe15..e955b98 100644 --- a/ttt/player.py +++ b/ttt/player.py @@ -1,4 +1,5 @@ from click import Choice, prompt +from strategy.lookahead_strategy import LookaheadStrategy from strategy.random_strategy import RandomStrategy 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."