-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (56 loc) · 1.87 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
import argparse
import random
import pygame
from game.game import Game
from game import constants
from game.solvers.breadth_first_search_longest import \
BreadthFirstSearchLongestPath
from game.solvers.breadth_first_search_shortest import \
BreadthFirstSearchShortestPath
from game.solvers.hamiltonian_cycle import HamiltonianCycle
from game.solvers.hamiltonian_cycle_optimised import HamiltonianCycleOptimised
from game.solvers.human import HumanSolver
from game.scores import ScoreLogger
models = [
HumanSolver(),
BreadthFirstSearchShortestPath(),
BreadthFirstSearchLongestPath(),
HamiltonianCycle(),
HamiltonianCycleOptimised(),
]
def args():
parser = argparse.ArgumentParser()
for model in models:
parser.add_argument(
"-" + model.abbreviation,
"--" + model.short_name,
help=model.long_name,
action="store_true"
)
parser.add_argument("-fps", "--fps", type=int, default=constants.FPS,
help="Frames per second")
return parser.parse_args()
if __name__ == '__main__':
pygame.init()
pygame.display.set_caption(constants.NAME)
args = args()
selected_game_model = random.choice(models)
for game_model in models:
if game_model.short_name in args and vars(args)[game_model.short_name]:
selected_game_model = game_model
score_logger = ScoreLogger(constants.SCORES_PATH)
g = Game(
game_model=selected_game_model,
fps=args.fps,
horizontal_tiles=constants.HORZ_TILES,
vertical_tiles=constants.VERT_TILES,
screen_width=constants.SCREEN_WIDTH,
screen_height=constants.SCREEN_HEIGHT,
score_logger=score_logger,
font=constants.FONT,
screen_depth=constants.SCREEN_DEPTH
)
play_game = True
while play_game:
play_game = g.tick()
pygame.quit()