-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
48 lines (38 loc) · 1.12 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
from board import TicTacToe
from players import User, MiniMaxBot
repeat_game = 'Y'
user = User()
bot = MiniMaxBot()
board = TicTacToe()
# game loop
while repeat_game != 'N' or repeat_game != 'n':
board.print_board()
status = 'TBD'
while status == 'TBD':
if board.check_status() != 'TBD':
break
else:
user_move = user.get_move()
board.set_state(user_move, 'USER')
board.print_board()
if board.check_status() != 'TBD':
break
else:
current_board_state = board.get_state()
bot_move = bot.get_move(current_board_state)
board.set_state(bot_move, 'BOT')
board.print_board()
status = board.check_status()
if status == 'USER':
user.set_tab()
elif status == 'BOT':
bot.set_tab()
repeat_game = input('Do you want to play again?[Yes|NO]')
if repeat_game.lower() == 'no':
print(f'USER win count: {user.get_tab()} and Bot win count: {bot.get_tab()}')
del user
del bot
del board
break
else:
board.reset_state()