-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAI_vs_AI.py
59 lines (44 loc) · 1.41 KB
/
AI_vs_AI.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
52
53
54
55
56
57
58
59
from utils import *
def AI_VS_AI(heuristic1, heuristic2):
board = []
for i in range(24):
board.append("x")
evaluation = evaluate()
print("Stage 1")
for i in range(9):
printBoard(board)
evalBoard = minimax(
board, ai_depth, True, alpha, beta, True, heuristic1)
if evalBoard.evaluate == float('inf'):
print("AI Bot 1 has won!")
exit(0)
else:
board = evalBoard.board
printBoard(board)
evalBoard = minimax(
board, ai_depth, False, alpha, beta, True, heuristic2)
if evalBoard.evaluate == float('-inf'):
print("AI Bot 2 has won!")
exit(0)
else:
board = evalBoard.board
print("Stage 2")
while True:
printBoard(board)
evalBoard = minimax(
board, ai_depth, True, alpha, beta, False, heuristic1)
if evalBoard.evaluate == float('inf'):
print("AI Bot 1 has won!")
exit(0)
else:
board = evalBoard.board
printBoard(board)
evaluation = minimax(
board, ai_depth, False, alpha, beta, False, heuristic2)
if evaluation.evaluate == float('-inf'):
print("AI Bot 2 has won")
exit(0)
else:
board = evaluation.board
if __name__ == "__main__":
AI_VS_AI(numPiecesHeuristic, potentialMillsHeuristic)