title: need advice for creating game AI -> javascript
body: <p>I am creating a pacman game in javascript to learn the language, and the most elements of it are done nicely except of.... the 4 ghosts AI. Right now I am using a pretty basic approach (like searching for x and y and try to get closer to pacman, if the ghosts hits a wall or other ghost e tries to unstuck himself by going into a random direction until it hits another wall or ghost). The thing is, this approach is just not good at all, most of the times ghosts get stuck between them for some time, or go to very erratic directions.
  What I want to ask is, what could be an approach for constructing this AI considering this is javascript? I am not asking for already done code here, just some ideas to get me unstuck on this.</p>
  
  <p>PS: I've thought of graphs and Disjktra et all, but, considering that the game is in a matrix and calculating 4 graphs + path every 250ms can be a lot costy....</p>