generated from mwc/lab_tic_tac_toe
(Commit summary. Replace this with a one-line description of this commit.)
initial commit What I changed (Replace this with a description of what you changed in this commit. This should be 1-2 sentences.) added notes.md Why I changed it (Describe why you made these changes. Were you working toward a goal? Did you reorganize your code? This should be 1-2 sentences.) explained states Estimate for remaining time to finish assignment: [1 day]
This commit is contained in:
parent
11fda02ae3
commit
25200368af
10
notes.md
10
notes.md
|
@ -24,15 +24,21 @@ TTTHuman player class, allows user to play actions base on list of availible act
|
|||
For each of the following board states, if you are playing as X
|
||||
and it's your turn, which action would you take? Why?
|
||||
|
||||
| O | O | | O | X | X | O |
|
||||
| O | O | | O x | X | X | O |
|
||||
---+---+--- ---+---+--- ---+---+--- ---+---+---
|
||||
X | X | | X | X | O | O | |
|
||||
X | X | x | X |x X | O | O | x |
|
||||
---+---+--- ---+---+--- ---+---+--- ---+---+---
|
||||
| | | | O | | | |
|
||||
|
||||
For #1, choosing 6 wins the game For # 2 choosing 6 blocks 0 from winning.
|
||||
For #3 choosing 0 gives a win on the next turn regardless of where 0 blocks.
|
||||
For #4 choosing 4 means 0 has block, then if x chooses 6 then win in 2 or 3.
|
||||
|
||||
### 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?
|
||||
|
||||
I think 0 menas the game is fair, 1 is more x wins a negative is more o wins.
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from ttt.player import TTTHumanPlayer, TTTComputerPlayer
|
|||
creates new player0, player1, game and view objects?
|
||||
'''
|
||||
player0 = TTTHumanPlayer("Player 1")
|
||||
player1 = TTTHumanPlayer("Player 2")
|
||||
player1 = TTTComputerPlayer("Player 2")
|
||||
game = TTTGame()
|
||||
view = TTTView(player0, player1)
|
||||
|
||||
|
|
|
@ -67,9 +67,9 @@ class TTTGame:
|
|||
for i in range(3):
|
||||
if currentState[i] == symbol and currentState[i+3] == symbol and currentState[i+6] == symbol:
|
||||
return True
|
||||
if currentState[0] == symbol and currentState[4] == symbol and currentState[8] == symbol:
|
||||
if currentState[4] == symbol and currentState[0] == symbol and currentState[8] == symbol:
|
||||
return True
|
||||
if currentState[2] == symbol and currentState[4] == symbol and currentState[6] ==symbol:
|
||||
if currentState[4] == symbol and currentState[2] == symbol and currentState[6] ==symbol:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
|
@ -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 #may need to delete ttt for this to work
|
||||
import random
|
||||
|
||||
|
@ -24,7 +24,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."
|
||||
|
|
Loading…
Reference in New Issue