-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
86 lines (63 loc) · 2.4 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import pygame
from constants import WIDTH, HEIGHT, SQUARE_SIZE
from game import Game
from minimax import minimax
from copy import deepcopy
from constants import *
window = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Runner and Chasers Game")
def get_row_col_from_mouse(pos):
x, y = pos
row = y // SQUARE_SIZE
col = x // SQUARE_SIZE
return row, col
def printArray(arr):
for row in arr:
for item in row:
print("{}".format(item), end = " ")
print("")
print("\n")
def main():
run = True
clock = pygame.time.Clock()
game = Game(window)
# round = int(input("Enter the number of turns: "))
# black_cell_number = int(input("Enter the number of black cells on the board: "))
# black_cell_number = game.board.black_cells
while run and game.round < 20:
clock.tick(60)
print("after {}'s play:\n".format(game.turn.name))
if game.turn.name == "R":
value, new_board = minimax(game.get_board(), 1, game.turn, game)
game.ai_move(new_board)
printArray(game.board.board)
print("after {}'s play:\n".format(game.turn.name))
if game.turn.name == "C1":
value, new_board = minimax(game.get_board(), 1, game.turn, game)
game.ai_move(new_board)
printArray(game.board.board)
print("after {}'s play:\n".format(game.turn.name))
if game.turn.name == "C2":
value, new_board = minimax(game.get_board(), 1, game.turn, game)
game.ai_move(new_board)
printArray(game.board.board)
"""
game.ai_move()
"""
if game.winner() != None:
print(game.winner())
run = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
"""
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
row, col = get_row_col_from_mouse(pos)
game.select(row, col)
"""
game.round += 1
game.update()
pygame.quit()
if __name__ == "__main__":
main()