This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (58 loc) · 1.72 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
import os
from game.game import Board
from players.human import HumanPlayer
from players.random import RandomPlayer
from players.minimax import MinimaxPlayer
def main():
# clear terminal
os.system("clear")
# print game info
print()
print(" --------------------------------")
print(" | |")
print(" | CONNECT 4 - UAIS PROJECT |")
print(" | |")
print(" --------------------------------")
# get player 1
print()
print(" Select player 1 type:")
print(" 1. Human")
print(" 2. Random")
print(" 3. Minimax")
choice = input()
while choice not in ("1", "2", "3"):
print(" invalid input, please try again")
choice = input()
if choice == "1":
player1 = HumanPlayer()
elif choice == "2":
player1 = RandomPlayer()
elif choice == "3":
player1 = MinimaxPlayer()
# get player 2
print()
print(" Select player 2 type:")
print(" 1. Human")
print(" 2. Random")
print(" 3. Minimax")
choice = input()
while choice not in ("1", "2", "3"):
print(" invalid input, please try again")
choice = input()
if choice == "1":
player2 = HumanPlayer()
elif choice == "2":
player2 = RandomPlayer()
elif choice == "3":
player2 = MinimaxPlayer()
board = Board(player1, player2)
playAgain = "Y"
while playAgain == "Y":
# this actually plays the game
board.playGame()
print(" Play again? (Y/N)")
playAgain = input().upper()
while playAgain not in ("Y", "N"):
playAgain = input().upper()
if __name__ == "__main__":
main()