-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (31 loc) · 1.07 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
"""
Input and output file creation functions and main part are implemented in this file.
To run, just type "python3 main.py" into the Console.
"""
import sys
from state import State
from typing import Tuple, List
from idastar import ida_star
from astar import a_star
def take_input() -> State:
with open('input.txt', 'r') as input_file:
goal: List[Tuple[int, int, int]] = []
for _ in range(3):
goal.append(tuple(map(lambda x: int(x), input_file.readline().split())))
input_file.readline()
initial: List[Tuple[int, int, int]] = []
for _ in range(3):
initial.append(tuple(map(lambda x: int(x), input_file.readline().split()))
)
return State(initial, goal)
if __name__ == '__main__':
print('Running...')
state: State = take_input()
sys.stdout = open('outputA.txt', 'w')
res = a_star(state)
if res is None:
print('fail')
sys.stdout = open('outputIDA.txt', 'w')
res = ida_star(state)
if res is None:
print('fail')