The author of this document has reversed engineered the Pacman code and detailed all the AI of the ghosts etc. If you have 15 minutes spare, its a fascinating insight into the gameplay mechanics.

http://www.atariage.com/forums/index.php?act=attach&type=post&id=118107