-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtictactoetest.py
45 lines (37 loc) · 1.08 KB
/
tictactoetest.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 24 13:07:26 2016
@author: peter086
"""
from tictactoe import *
from tictactoeAI import *
testEmptyM = [[0,0,0],[0,0,0],[0,0,0]]
testM = [[0,1,2],[1,2,0],[1,0,2]]
board = Board(3, testM)
board.show()
assert board.hasStone(1,1) == 2
assert len(board.getEmptySpots()) == 3
assert not board.whoHasWon()
assert board.placeStone(0,0,2)
assert len(board.getEmptySpots()) == 2
assert board.whoHasWon() == 2
assert not board.placeStone(1,2,1)
board.show()
board = Board(3, testM)
turns = createPossibleMoves(board, 1)
for t in turns:
print t
board = Board(3)
# turns = createPossibleMoves(board, 1)
# for t in turns:
# print t
#playshellgame()
testsize=4
for i in range(testsize / 2 + 1):
for j in range(i+1):
game = Game(size=testsize)
outcome = game.playTurn(i, j)
while outcome == 0:
move = findBestMove(game.getBoard(), game.getTurnPlayer(), maxrecursion=4)
outcome = game.playTurn(move.row, move.column)
raw_input("Ready for the next game?")