I made the computer deterministic and updated the

code to import the LookaheadStartegy to the class player.py.

As I worked through the lab I found myself coming back to the web that
was given to us in the lab itself. When I play games like Rumicube and
tic tac toe the process of running scenarios in my head happens instantaneously.
Prepping the computer to play this way as well is complex.

The reward system is a straightforward and interesting way to evaluate the "goodness" of
a move. How good is it to do one thing rather than another? The ability to think all the way through the
options is really interesting to evaluate and think about! Overall my cognition maybe did less in
the way of changing, but developed a meta-like awareness for the process it goes through when it's
problem solving.
This commit is contained in:
Rebecca Hankey
2024-11-23 15:23:13 -05:00
parent ec7b133190
commit fb996aeba2
4 changed files with 12 additions and 4 deletions

View File

@@ -68,14 +68,15 @@ class TTTGame:
[0, 4, 8],
[2, 4, 6],
]
for combo in combos:
for combo in combo:
if self.check_winning_combo(state, symbol, combo):
return True
return False
def check_winning_combo(self, state, symbol, combo):
"Checks to see if the X's and O'x are in a row, column, or diagonal- to create a winning three in a row."
for index in combo:
if state["board"][index] != | symbol:
if state["board"][index] != symbol:
return False
return True

View File

@@ -2,6 +2,7 @@ from click import Choice, prompt
from strategy.random_strategy import RandomStrategy
from ttt.game import TTTGame
import random
from strategy.lookahead_strategy import LookaheadStrategy
class TTTHumanPlayer:
"A human tic tac toe player."
@@ -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."