-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
51 lines (46 loc) · 1.57 KB
/
test.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
46
47
48
49
50
51
from board import Board
from constants import BLACK, WHITE
from minimax_player import MinimaxPlayer
from greedy_player import GreedyPlayer
from random_player import RandomPlayer
from expectimax_player import ExpectimaxPlayer
from ids_player import IterativeDeepeningPlayer
from alphabeta_player import AlphaBetaPlayer
from heuristic_player import HeuristicPlayer
from referee import Referee
def board_test():
b = Board()
moves = b.get_valid_moves(BLACK)
print(moves == [(2, 3), (4, 5), (3, 2), (5, 4)])
for i in range(0, 3):
for j in range(0,3):
b.board[j][i] = BLACK
b.board[1][1] = None
b.render()
print(b.get_valid_moves(BLACK))
def board_game_test():
b = Board()
b.render()
for _ in range(0, 20):
moves = b.get_valid_moves(BLACK)
print("MOVES", moves, BLACK)
new_b = b.apply_move(moves[0], BLACK)
new_b.render()
moves = new_b.get_valid_moves(WHITE)
print("MOVES", moves, WHITE)
new_w = new_b.apply_move(moves[0], WHITE)
new_w.render()
b = new_w
def game_test(player1, player2):
ref = Referee([player1, player2])
scores = ref.play_game()
print("GAME RESULTS: ", scores)
# game_test(HeuristicPlayer(), HeuristicPlayer())
# game_test(IterativeDeepeningPlayer(), IterativeDeepeningPlayer())
# game_test(MinimaxPlayer(), MinimaxPlayer())
# game_test(GreedyPlayer(), GreedyPlayer())
# game_test(RandomPlayer(), RandomPlayer())
# game_test(ExpectimaxPlayer(), ExpectimaxPlayer())
# game_test(AlphaBetaPlayer(), AlphaBetaPlayer())
# board_game_test()
# board_test()