-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.py
32 lines (27 loc) · 946 Bytes
/
Game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys, math, Players
from Boards import Board
from Players import MinimaxPlayer, HumanPlayer
class Game:
def __init__(self, P1 = HumanPlayer("X"), P2 = HumanPlayer("O")):
self.board = Board()
self.isP1 = True
self.finalState = False
self.Player1 = P1
self.Player2 = P2
print "Game Started"
while self.finalState == False:
self.board.Print()
if self.isP1:
if self.Player1.Play(self.board):
self.isP1 = not self.isP1
else:
if self.Player2.Play(self.board):
self.isP1 = not self.isP1
self.finalState = self.board.WinCondition()
self.board.Print()
if self.finalState == "X":
print "X wins!!!"
elif self.finalState == "O":
print "O wins!!!"
else:
print "Draw"