I'm currently making a Pacman game in java. I have a question about the ghosts though.
I understand that the ghosts do not all have the same style of attack. I first want to work on the basics of getting the ghost to go after the Pacman and not worry about there differences yet.
My question to you smart people out there is what would be the best way to make the ghosts chase the Pacman but sometimes randomly divert paths. I'm currently using a 21 by 21 2D array for telling where walls are and such so I was thinking to make it more try and head for the current grid location of Pacman. (for example, go to 10,14) Of course while avoiding going through walls like Pacman. I'm wondering how I could make it do this and also have the ghosts sometimes stop and go another direction or something so that it's not always a constant chase and Pacman has a chance to get away. Maybe some of you have programmed a Pacman game or just know a good way for this. Any help would be greatly appreciated.
(Please note I'm currently in a Grade 11 Computer Science course and halfway through the first semester ever of learned java).