I made a function that somewhat works, but it also adds unwated connections. And its a BIG mess.
func check_for_loops(point, known_path, potential_paths, initial_loop):
potential_paths
var connections = get_connected_positions(point)
for i in connections:
if i in known_path:
continue
if i in potential_paths:
continue
potential_paths.append(i)
printt("get_connected_positions: ",i)
if potential_paths.size() > 3:
for i in get_connected_positions(potential_paths.front()):
if i == initial_loop:
print("loop_completed: ", potential_paths)
return potential_paths
if !potential_paths.empty():
check_for_loops(potential_paths.front(), known_path, potential_paths, initial_loop)
return potential_paths
The function is called from check_for_path()
, I added an else
after if not path_to_end.empty():
