-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
65 lines (52 loc) · 1.91 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
from board import Board
from brute import Brute
from gui import Gui
from cli import Cli
import crook
import time
board = Board()
ans = input("Select mode (cli/gui/compare): ")
if ans == "cli" or ans == "gui":
brute = Brute(board)
while(1):
file_name = input("What board would you like? (easy/medium/hard/insane): ")
if file_name not in ["easy", "medium", "hard", "insane"]:
print("Invalid puzzle")
else:
break
board.parse_board("boards/" + file_name + ".txt")
if ans == "cli":
cli = Cli(board, brute)
cli.start()
else:
gui = Gui(board, brute)
gui.start()
elif ans == "compare":
board = Board()
puzzles = ["boards/easy.txt", "boards/medium.txt", "boards/hard.txt", "boards/insane.txt"]
for puzzle in puzzles:
print("======================================================")
print(puzzle)
print()
#Brute force method
print("Brute force solution")
board.parse_board(puzzle)
brute = Brute(board)
start = time.time()
brute.solve()
end = time.time()
brute_time = end - start
board.print()
#Crook method (partial)
print("Partial Crook method solution")
board.parse_board(puzzle)
start = time.time()
crook.crook_incomplete(board)
end = time.time()
crook_time = end - start
board.print()
#Print results
print("Brute time: {:f} seconds".format(brute_time))
print("Crook time: {:f} seconds".format(crook_time))
else:
print("Invalid option, goodbye!")