Completed the tasks for checkpoint 3

What I changed
Answered the questions and gave the computer a better strategy.

Why I changed it
I answered the questions to the best of my abilitiy. I gave the computer a better strategy as instructed.

Estimate for remaining time to finish assignment: 30 minutes
This commit is contained in:
root 2024-02-14 23:44:21 -05:00
parent ca1c558686
commit f5b1b03b9a
3 changed files with 10 additions and 2 deletions

View File

@ -27,9 +27,16 @@ and it's your turn, which action would you take? Why?
---+---+--- ---+---+--- ---+---+--- ---+---+---
| | | | O | | | |
For the first board I would play 5 because I would win.
For the second board I would play 5 because I would block O from winning.
For the third board I would play 0 because I would be guaranteed a board where I could always win next turn.
For the third board I would play 4 because it gets me closer to winning and blocks O from getting closer
### 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 reward state is 0, which means the game is either incomplete or it has ended in a draw. In this case, the game is incomplete.
The future reward state is 0, which means if both players play optimally, the game will end in a draw.

View File

@ -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("Robot")
game = TTTGame()
view = TTTView(player0, player1)

View File

@ -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."