-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_water_jug_problem.py
33 lines (26 loc) · 1.34 KB
/
test_water_jug_problem.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
from simpleai.search import *
import jugs_problem
max_capacity_list = []
target_volume_list = []
for i in range(3):
max_capacity = input(f"Enter max capacity for Jug{i + 1}: ")
max_capacity = int(max_capacity)
max_capacity_list.append(max_capacity)
for i in range(3):
target_volume = input(f"Enter target volume for Jug{i + 1}: ")
target_volume = int(target_volume)
target_volume_list.append(target_volume)
problem = jugs_problem.JugsProblem(max_capacity=(max_capacity_list[0], max_capacity_list[1], max_capacity_list[2]),
target_volume=(target_volume_list[0], target_volume_list[1], target_volume_list[2]))
result = breadth_first(problem, graph_search=True, viewer=jugs_problem.my_viewer)
# result = depth_first(problem, graph_search=True, viewer=jugs_problem.my_viewer)
# result = iterative_limited_depth_first(problem, graph_search=True, viewer=jugs_problem.my_viewer)
# result = limited_depth_first(problem, graph_search=True, viewer=jugs_problem.my_viewer, depth_limit=10)
# result = limited_depth_first(problem, graph_search=True, viewer=jugs_problem.my_viewer, depth_limit=10)
# result = uniform_cost(problem, graph_search=True, viewer=jugs_problem.my_viewer)
i = 1
for path in result.path():
print(f"{i}- {path}")
i += 1
print(f"Total cost: {result.cost}")
print(jugs_problem.my_viewer.stats)