-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplay.py
More file actions
57 lines (43 loc) · 1.69 KB
/
Copy pathplay.py
File metadata and controls
57 lines (43 loc) · 1.69 KB
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
52
53
54
55
56
57
import chess
import human
import randomAI
import decisionTreeAI
import scikitLinearAI
def play(printGame = True):
board = chess.Board()
if printGame:
print(board)
print("Let's start with this game of chess")
# player1 = human.Human("Player 1")
# player1 = randomAI.RandomAI("Player 1")
player1 = decisionTreeAI.DecisionTreeAI("Player 1", chess.WHITE, 3)
player2 = decisionTreeAI.DecisionTreeAI("Player 2", chess.BLACK, 3)
# player2 = decisionTreeAI.DecisionTreeAI("Player 2", chess.BLACK, 3, False, 0.2)
# player1 = decisionTreeAI.DecisionTreeAI("Player 1", chess.WHITE, 3, False, 0, True, False)
# player2 = decisionTreeAI.DecisionTreeAI("Player 2", chess.BLACK, 3, False, 0, False, True)
# player2 = decisionTreeAI.DecisionTreeAI("Player 2", chess.BLACK, 3, True)
# player2 = scikitLinearAI.ScikitLinearAI("Player 2", chess.BLACK, 1, True)
while (not board.is_game_over()):
if printGame:
print('\n', player1.description, 'will now play')
player1Move = player1.move(board)
board.push(player1Move)
if printGame:
print(board)
if printGame:
print('\n', player2.description, 'will now play')
player2Move = player2.move(board)
if player2Move == -1:
if printGame:
print('\nResult:', board.result())
print('Number of plys:', board.fullmove_number)
return board
board.push(player2Move)
if printGame:
print(board)
if printGame:
print('\nResult:', board.result())
print('Number of plys:', board.fullmove_number)
return board
if __name__ == '__main__':
play()