Explore Courses Blog Tutorials Interview Questions
0 votes
in AI and Deep Learning by (50.2k points)

I am creating a Pacman game in javascript to learn the language, and the most elements of it are done nicely except... 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 hit a wall or other ghost e tries to unstick 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 time 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 in javascript? I am not asking for already done code here, just some ideas to get me unstuck on this.

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 costly...

1 Answer

0 votes
by (108k points)

You can refer to the following link for the implementation of PacMan. It is written in Javascript, CSS, and HTML:

Here is a tutorial for advanced JavaScript techniques for PacMan.

This text describes the planning, set up, and development of a complex JavaScript-application.

Browse Categories