Well the best way to go about this kind of Ai would be to think about what is actually required, because you'll have to balance the code for intelligence against processor speed.
This oftenly leads to a slightly more randomised effect than most people would like, but the only way sometimes.
There should be a pathfinding routine, which personally I'd use an array to setup numbers to tell the program on each square were walls are.
using a simply bit per wall wouldn't be hard as you get 8 bits per byte so like 6 bits for possible walls.
From that the routine can then like check where pacman is, and make a possible route calc ... if you combine that with a link checker so they take it in turns the closest to him gets to pick randomly a route then each of the others futher away get to randomly pick a route that doesn't intersect. That would kinda get the effect you are looking for. If they're in scared mode, then they should calc all routes say 10squares away which don't end in a three sided wall square, and randomly pick one.
I mean you could always have the program also calc which would give him the best chance for escape, but as i mentioned processor calc's cause this has gotta be done per second.
You also have to think how will the user react if you make the ghost so intelligent they can't be touched but are on you instantly.
Another thing you could add is LOS so unless pacman comes into thier veiw they tinker about but just checking the clear squares based on the ghosts current travel direction.
I mean the setup is oftenly different for almost everygame due to what the enemy is to do, but the same principals are to be relied upon.
Speed vs Randomness ... you can make them sit there and figure out the best possible action, like in half-life if a grunt get more than 20% dmg he'll find the nearest wall and hide but randomly he can crouch and keep firing or just try to find the nearest exit, or even follow a friend who's also escaping.
in the end they could have gone to make them think carefully about what to do, but randomness was chosen for somethings for speed.
Also take into account about difficulty levels, if you give set options to choose from - even randomly you're guarenteed what they'll do and making them slightly predicatable will make them easier. Taking away that predictability will take away that difficulty.
So for an easi version of Pacman, you could tell the ghosts to say go down route 1 all the time unless they bump into another ghost then they change to that new first route
hope this is all helpful
Anata aru kowagaru no watashi!