-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (32 loc) · 1.27 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
import algorithms
from algorithms import *
from input import *
def process_main_input(map_name: str = None) -> None:
while True:
keyboard_input, mouse_input = process_input()
if mouse_input != IDLE:
draw_char(*mouse_input) # Draws the given character, based on the mouse input.
if keyboard_input == CLEAR:
clear() # Clear display
elif keyboard_input == START:
regress()
algorithms.ALGORITHMS[input.current_function_index]() # Call the pathfinding algorithm
elif keyboard_input == BACK_SEARCH:
regress()
elif map_name is not None and keyboard_input == RESET:
"""
Reload map from the file.
Alternatively, we can save the configuration and reload it,
but this way it is more rewarding visually.
"""
load_map(map_name)
def main(map_name: str = None) -> None:
# Sets a caption for the window
set_caption(f"{config.algo_names[0]:} | {config.NODE_SYMBOLS[0]:}".center(25))
if map_name is not None:
# Load the map for the first time.
process_input()
load_map(map_name)
process_main_input(map_name)
if __name__ == "__main__":
main("basic_maze.txt")