Skip to content

Instantly share code, notes, and snippets.

@poemdexter
Created April 10, 2012 02:51
Show Gist options
  • Save poemdexter/2348052 to your computer and use it in GitHub Desktop.
Save poemdexter/2348052 to your computer and use it in GitHub Desktop.
def backtrack_through_closed
final_path = []
next_position = @closed_list.select{|x| x[2] == @finish}[0][2]
final_path.unshift(next_position)
while next_position != @start
next_position = @closed_list.select{|x| x[2] == next_position}[0][3]
final_path.unshift(next_position)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment