Checkpoint 3

As I worked through this lab and the video, I became more aware of
the thought process that goes into tic-tac-toe. However, it was not
until I saw all the reward possibilities for the initial state of the
board, and then made the computer play itself that I appreciated how
complex the game is and how many possibilities there are on a relatively
simple board. I am also wondering when the computer plays itself,
does the game always end in a tie? I suppose I could write a program for
this that plays the game a set number of times and makes a list of the
outcomes and then counts the wins, losses, and ties for a particular
player.
This commit is contained in:
Chris Mekelburg
2024-11-17 21:37:11 -05:00
parent 2d470c3c89
commit 48dd6717e4
3 changed files with 16 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
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,10 +24,10 @@ 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."
"Chooses the best move from the moves available."
action = self.strategy.choose_action(state)
print(f"{self.name} chooses {action}.")
return action