Generating random Pac-Man mazes is a deceptively difficult problem that I spent some months working on. It is not easy to describe clearly. I hope you are patient. This page is an effort to begin communicating how the algorithm works.
http://shaunlebron.github.io/pacman-mazegen/
http://shaunlebron.github.io/pacman-mazegen/