Memory Bounded Search Algorithm
Memory Bounded Search Algorithm
class Node:
def __init__(self, state, parent=None, action=None):
self.state = state
self.parent = parent
self.action = action
while open_list:
if memory_usage(open_list, closed_list) > memory_limit:
prune_memory(open_list, closed_list)
current_node = select_best_node(open_list)
# Return the goal node
if is_goal(current_node):
return current_node
open_list.remove(current_node)
closed_list.append(current_node)
# Example usage
initial_state = (1, 2, 3, 4, 5, 6, 0, 7, 8) # Initial state of the
puzzle
Output:
Case 1 with Memory Limit 1
Memory limit exceeded. No solution found within the given
memory limit.
Action: 7
State:
(1, 2, 3)
(4, 5, 6)
(7, 0, 8)