How is the program running?
Pac-Man Movement:
Pac-Man moves based on the aim direction, and the program validates if the movement is allowed using valid().
When Pac-Man eats a dot (tiles[index] == 1), the score increases.
Ghost Movement:
Ghosts chase Pac-Man if within 100 units.
If a move is invalid (e.g., collides with a wall), ghosts randomly change direction.
Game Over Condition:
If a ghost comes within 20 units of Pac-Man, the game ends.
Movement logic
Other components
Validate movement
Checks if the target point is not a wall (tiles[index] == 0).
Ensures Pac-Man and ghosts stay aligned to the grid.


The world() function creates the maze and places dots for Pac-Man to eat.
It uses the tiles list to define the maze layout.
square() draws walls and paths.
The change() function allows the user to control Pac-Man using the arrow keys.
Starts the game loop with move().
The core of the program lies in the move() function for handling Pac-Man and ghost movements and the valid() function for path validation. The rest (world setup, user controls, etc.) is auxiliary for the game's structure and interaction.