title: How to find path using BFS in corners search of Pacman search project
body: <p>I am trying to solve <a href="http://inst.eecs.berkeley.edu/~cs188/pacman/html/navigation.html?page=p1/p1_q5" rel="nofollow">this</a> problem of the Berkley Pacman Search Project. The question states that I need to solve <a href="http://inst.eecs.berkeley.edu/~cs188/pacman/html/navigation.html?page=p1/p1_q2" rel="nofollow">bfs</a> problem first, and then only change the representation of goal state to solve the corners problem. <br/>
  <a href="https://dpaste.de/kxu5" rel="nofollow">Here</a> is my code of bfs which returns the smallest path from root to a state. </p>
  
  <p>Now issue with my <a href="https://dpaste.de/tZoR" rel="nofollow">isGoalState function</a> is , that when all the four corners are visited it tells the goalstate is achieved, but the bfs function realizes that that goal state is only the last corner position. Hence gives me a path from the starting position of Pacman to the last corner, and not the path covering all the corners</p>
  
  <p>Can u tell how should I modify my bfs function, and goal state function to accommodate this. I tried looking at the solutions on net, but couldn't find one that is correct.</p>
  
  <p>Also I think the solution to this problem should be a generalized bfs with a goal state function provided, that should work in normal cases too. </p>