-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
98 lines (80 loc) · 3.07 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
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python3
"""
Usage:
python3 RuzzleGraph.py -m1 PORT --> execution time study
"""
from subprocess import *
import sys
from threading import *
from ClientDictionnaire import *
from RuzzleMatrix import *
from ServerGame import *
from ClientGame import *
from Vertex import *
from ArbreLex import *
from ListeMots import *
from RuzzleGraph import *
def main():
# initialisation variables
langue = ""
parcourDictionnaire = ""
for par in sys.argv:
if par == "en":
langue = "en"
parcourDictionnaire = "./ressources/dictEn"
if par == "fr":
langue = "fr"
parcourDictionnaire = "./ressources/dictFr"
# creation de la grille de jeu
ruzzle = RuzzleMatrix(langue)
grafoRuzzle = RuzzleGraph(ruzzle.vertexMatrixToGraph(), None)
# methode 1 (ArbreLexServeur C)
if sys.argv[1] == "-m1":
grafoRuzzle.affichageTableRuzzle()
print("\n\n")
grafoRuzzle.dictionnaire = ClientDictionnaire(int(sys.argv[2]))
grafoRuzzle.generationM1(True)
# methode 1b (ArbreLex en Python)
elif sys.argv[1] == "-m1b":
grafoRuzzle.affichageTableRuzzle()
print("\n\n")
grafoRuzzle.generationM1b(parcourDictionnaire, True)
# methode 2 (ArbreLex en Python)
elif sys.argv[1] == "-m2":
grafoRuzzle.affichageTableRuzzle()
print("\n\n")
grafoRuzzle.generationM2(grafoRuzzle, parcourDictionnaire, True)
# Statistiques - Comparation de performances m1 - m1b - m2
elif sys.argv[1] == "-s":
grafoRuzzle.dictionnaire = ClientDictionnaire(int(sys.argv[2]))
grafoRuzzle.affichageTableRuzzle()
print("Methode 1 (ArbreLexServeur C) --> ")
grafoRuzzle.generationM1(False)
grafoRuzzle.listeMotsDansGrille = ListeMots()
print("Methode 1b (ArbreLex Python) --> ")
grafoRuzzle.generationM1b(parcourDictionnaire, False)
grafoRuzzle.listeMotsDansGrille = ListeMots()
print("\nMethode 2 (Py - Parcours Diction) --> ")
grafoRuzzle.generationM2(grafoRuzzle, parcourDictionnaire, False)
# Multiplayer Mode - Server Side
elif sys.argv[1] == "-server":
print("Generation Liste Mots A Trouver...")
grafoRuzzle.generationM2(grafoRuzzle, parcourDictionnaire, False)
print("\nEn attente de connexion pour une defi!")
serverGame = ServerGame('localhost', int(sys.argv[2]), grafoRuzzle)
serverGame.waitForOpponent()
# Multiplayer Mode - Client Side
elif sys.argv[1] == "-client":
print("Generation Liste Mots A Trouver...")
grafoRuzzle.generationM2(grafoRuzzle, parcourDictionnaire, False)
clientGame = ClientGame(sys.argv[2], int(sys.argv[3]), grafoRuzzle)
temps = int(input("saisir temps du defi : "))
clientGame.sendChallenge(temps)
# mode Single Player
else:
dictionnaire = ArbreLex(parcourDictionnaire)
dictionnaire.chargeDictionnaire(parcourDictionnaire)
dictionnaire.generePossiblesMots(grafoRuzzle)
grafoRuzzle.playOneMatch()
if __name__ == "__main__":
main()