so i am currently making a pacman game and need to make a function of some sort that can give 4 outputs to decide wether the ghost should go up down left or right in order to chase the player
[0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0]
[0 2 0 0 0 1 0 0 0 1 1 0 1 0 1 0 0 0 1 0]
[0 1 0 0 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0]
[0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0]
[0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0]
[0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0]
[1 1 1 1 1 1 0 3 1 1 1 1 1 0 1 1 1 1 1 1]
[0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0]
[0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0]
[0 1 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 0]
[0 1 0 0 1 0 1 0 1 1 1 1 0 1 0 1 0 0 1 0]
[0 1 0 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0]
[0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
i currently have this array where 1 is a wall 0 is free space to move into 2 is the players position and 3 is the ghost position and i only need it to determine the first movement it should take as it will re run the function when the player next moves one tile and i was just wondering if anyone was able to provide a possible solution as i am very stuck. also diagonal movement is not aloud. thank you