implemented dijkstra for reachable positions