How to move like Pacman/Snake using Raycasts inside a 2D array ?

I have a grid based level with each grid sized 1x1 unit(default). How do I make my gameobject move through the lanes accelerating in a specific direction (Pacman) until an input is given to change its’ direction, or if it collides with a deadend wall and turns to its’ right ?
The movement needs to be aligned to the middle of the tile. An example of the level with the player object is given below. The green object is the player and red cylinder is a goal, and the scenario in the picture is when no input button was pressed, hereby allowing the player object to auto-turn left.

alt text

Pacman movement is done using a 2D array of possible positions. I would build an array for each level, then use that array for collision detection.