from Strategies.strat import PathFindingStrategy
from Strategies.path import restore
from collections import deque

class BFS(PathFindingStrategy):
    def findPath(self, maze, start, exit):
        if exit is None:
            return [], 0

        queue = deque([start])
        visited = {start}
        parent = {}

        while queue:
            current = queue.popleft()

            if current == exit:
                break

            for n in maze.getNeighbors(current):
                if n not in visited:
                    visited.add(n)
                    parent[n] = current
                    queue.append(n)

        return restore(parent, start, exit), len(visited)