-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLMsolverUI.py
More file actions
42 lines (38 loc) · 1.24 KB
/
LMsolverUI.py
File metadata and controls
42 lines (38 loc) · 1.24 KB
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
from LMsolver import *
import time
first_flag = True
while True:
if first_flag:
print('Welcome to use this simple line maze solver!!')
first_flag = False
else:
print()
print('Please enter the action number which you want to perform.')
print('(1) Use solver')
print('(2) Exit from solver')
action_number = input('Action number: ')
try:
N = int(action_number)
except ValueError:
print('Not a number!')
continue
if N == 1:
print('Please enter the file name of line maze map.')
file_name = input('Map file name: ')
line_maze_map = build_map(file_name)
if line_maze_map == None:
continue
start_clk = time.clock()
answer_path = dfs_solver(line_maze_map)
end_clk = time.clock()
if len(answer_path) == 0:
print('This puzzle has no answer.')
continue
else:
print('It took', '%f' % (end_clk - start_clk), 'seconds to solve this puzzle.')
write_answer(file_name, line_maze_map.n_row, line_maze_map.n_col, answer_path)
print('Answer file generated!')
elif N == 2:
break
else:
print('Invalid action number!')