-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
82 lines (55 loc) · 1.69 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
"""
File: main.py
File Created: 16/07/2022
Authors: Louis Geisler, Emile Duquennoy
"""
from textwrap import dedent
from utils.FilesUtils import get_list_imported_classes
import players
import games
PLAYERS = get_list_imported_classes(players)
GAMES = get_list_imported_classes(games)
def Partie(Partie,*lJoueur):
lJoueur = lJoueur[0](Partie),lJoueur[1](Partie)
print("-"*30)
Etat=(False,0)
while not Etat[0]:
Partie.Affichage()
available_moves = [Partie.Coup2Affiche(c) for c in Partie.lCoupJouable]
print(dedent(f"""\
Round N°{Partie.nTour}
Current player: {lJoueur[Partie.nTour%2]}
Players:
X: {lJoueur[0]}
O: {lJoueur[1]}
Possible moves: {available_moves}
"""))
coup=lJoueur[Partie.joueur].Choix(Partie)
Etat=Partie.Jouer(coup)
print(dedent(f"""\
Last move: {Partie.Coup2Affiche(coup)}
Eta: {Etat}
"""))
Partie.Affichage()
winner = (lJoueur[0], "Tie", lJoueur[1])[Etat[1]+1]
print(dedent(f"""\
Game Over !
Score: {Etat[1]}
Eta: {Etat}
Winner: {winner}
"""))
if __name__ == "__main__":
# Choice of game to play
print("Games available:")
for i,jeu in enumerate(GAMES):
print(f" {i})",jeu.__name__)
Jeu=GAMES[int(input(f"Which game do you want to play? (number) "))]
# The type of player for the game
print("\nPlayers available:")
for i,joueur in enumerate(PLAYERS):
print(f" {i})",joueur.__name__)
lJ=[]
for i in [1,2]:
lJ+=[PLAYERS[int(input(f"Player{i}'s type: "))]]
print("-"*30)
Partie(Jeu(),*lJ)