Skip to content

Commit

Permalink
Edited linear puzzle problem. 📤
Browse files Browse the repository at this point in the history
  • Loading branch information
RodolfoFerro committed Dec 28, 2018
1 parent 5446997 commit 4422707
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions linear_puzzle_bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def border_operator(node):
return Node(operated_data)


def search_solution_with_bfs(initial_state, solution):
def solution_with_bfs(operators, initial_state, solution):
"""
Function that generates new states from the initial state (using the
defined operators) to solve the Linear Puzzle with four elements by
Expand All @@ -52,8 +52,6 @@ def search_solution_with_bfs(initial_state, solution):
visited, border = [], []
initial_node = Node(initial_state)
border.append(initial_node)
opertators = [left_operator, center_operator,
right_operator, border_operator]

# While we border nodes is not empty and puzzle not solved:
while len(border) > 0:
Expand Down Expand Up @@ -84,8 +82,12 @@ def search_solution_with_bfs(initial_state, solution):
initial_state = [1, 4, 3, 2]
solution = [1, 2, 3, 4]

# Define operatos list:
opertators = [left_operator, center_operator,
right_operator, border_operator]

# Compute solution:
solution_node = search_solution_with_bfs(initial_state, solution)
solution_node = solution_with_bfs(opertators, initial_state, solution)

# Build steps (by getting the father nodes of the solution):
resulting_path = []
Expand Down

0 comments on commit 4422707

Please sign in to comment.