-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
143 lines (132 loc) · 4.76 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import pygame
from Utility import ui
from Level.level_one import Level
from Level.level_pathfinding import Level_PathFinding
from Level.level_neuro_evolution import LevelNeuroEvolution
from Character.player import Player
class Main:
def __init__(self):
self.player = Player(
step=10, draw=False, x=30, y=200, length=30, width=30, color=(230, 220, 50)
)
self.gameDimension = (700, 400)
self.gameDisplay = pygame.display.set_mode(self.gameDimension)
self.clock = pygame.time.Clock()
self.resume = False
# self.level = Level_PathFinding(self.player, game_dimension=self.gameDimension, screen_capt=False, stream=False,
# gray=False, maxi=False, store=False))
def pause_game(self, *args):
self.resume = False
while not self.resume:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
self.gameDisplay.fill((180, 180, 180))
ui.message(
gameDisplay=self.gameDisplay,
msg="Welcome, select your option !",
x=self.gameDimension[0] // 2 - 80,
y=30,
)
ui.button(
gameDisplay=self.gameDisplay,
message="Play yourself",
x=self.gameDimension[0] // 2 - 330,
y=100,
width=300,
height=40,
inactive_color=(100, 101, 112),
active_color=(50, 50, 56),
action=lambda: self.initiate_level(Level),
)
ui.button(
gameDisplay=self.gameDisplay,
message="A* Algorithm",
x=self.gameDimension[0] // 2 - 330,
y=150,
width=300,
height=40,
inactive_color=(100, 101, 112),
active_color=(50, 50, 56),
action=lambda: self.initiate_level(Level_PathFinding),
)
# to be activated
ui.button(
gameDisplay=self.gameDisplay,
message="BFS Algorithm(to be enabled)",
x=self.gameDimension[0] // 2 - 330,
y=200,
width=300,
height=40,
inactive_color=(211, 211, 213),
active_color=(211, 211, 213),
action=None,
)
# to be activated
ui.button(
gameDisplay=self.gameDisplay,
message="DFS Algorithm(to be enabled)",
x=self.gameDimension[0] // 2 - 330,
y=250,
width=300,
height=40,
inactive_color=(211, 211, 213),
active_color=(211, 211, 213),
action=None,
)
# to be activated
ui.button(
gameDisplay=self.gameDisplay,
message="Dijkstra's Algorithm(to be enabled)",
x=self.gameDimension[0] // 2 - 330,
y=300,
width=300,
height=40,
inactive_color=(211, 211, 213),
active_color=(211, 211, 213),
action=None,
)
# to be activated
ui.button(
gameDisplay=self.gameDisplay,
message="Neuro Evolution",
x=self.gameDimension[0] // 2 + 30,
y=100,
width=300,
height=40,
inactive_color=(100, 101, 112),
active_color=(50, 50, 56),
action=lambda: self.initiate_level(LevelNeuroEvolution),
)
# to be activated
ui.button(
gameDisplay=self.gameDisplay,
message="DQN(to be enabled)",
x=self.gameDimension[0] // 2 + 30,
y=150,
width=300,
height=40,
inactive_color=(211, 211, 213),
active_color=(211, 211, 213),
action=None,
)
pygame.display.update()
self.clock.tick(30)
def initiate_level(self, level):
self.level = level(
self.player,
game_dimension=self.gameDimension,
screen_capt=False,
stream=False,
gray=False,
maxi=False,
store=False,
)
self.resume = True
def start(self):
self.pause_game()
self.level.start_game()
if __name__ == "__main__":
main = Main()
main.start()