Checkpoint 3

I realized that even simple things take quite a bit of thought when it comes
to creating games using code. I had to really think about how this game works
in order to fully understand the lab.
This commit is contained in:
Lauren Dawnkaski 2024-11-30 16:19:29 -05:00
parent 8aac402bb7
commit 2973afd95f
3 changed files with 9 additions and 3 deletions

View File

@ -31,9 +31,15 @@ and it's your turn, which action would you take? Why?
---+---+--- ---+---+--- ---+---+--- ---+---+--- ---+---+--- ---+---+--- ---+---+--- ---+---+---
| | | | O | | | | | | | | O | | | |
board #1: position 0, to block the O's from getting 3 in a row.
board #2: position 6, to block the O's from getting 3 in a row.
board #3: position 0, because I do not need to block O's and this will allow me to have 2 places to get 3 in a row.
board #4: position 4, because I will be tring to get 3 in a row.
### Initial game state ### Initial game state
You can get the inital game state using game.get_initial_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? What is the current and future reward for this state? What does this mean?
currently there is no reward for the inital state because all the spots are blank and nobody has won yet. We could also be at a this state after the game resets. Either a player will gain a point by winning or nobody gets a point if there is no winner.

View File

@ -3,7 +3,7 @@ from ttt.view import TTTView
from ttt.player import TTTHumanPlayer, TTTComputerPlayer from ttt.player import TTTHumanPlayer, TTTComputerPlayer
player0 = TTTHumanPlayer("Player 1") player0 = TTTHumanPlayer("Player 1")
player1 = TTTHumanPlayer("Player 2") player1 = TTTComputerPlayer("Robot")
game = TTTGame() game = TTTGame()
view = TTTView(player0, player1) view = TTTView(player0, player1)

View File

@ -1,5 +1,5 @@
from click import Choice, prompt from click import Choice, prompt
from strategy.random_strategy import RandomStrategy from strategy.lookahead_strategy import LookaheadStrategy
from ttt.game import TTTGame from ttt.game import TTTGame
import random import random
@ -24,7 +24,7 @@ class TTTComputerPlayer:
def __init__(self, name): def __init__(self, name):
"Sets up the player." "Sets up the player."
self.name = name self.name = name
self.strategy = RandomStrategy(TTTGame()) self.strategy = LookaheadStrategy(TTTGame(), deterministic=False)
def choose_action(self, state): def choose_action(self, state):
"Chooses a random move from the moves available." "Chooses a random move from the moves available."