### 1. Performance Evaluation

The shortest path is shown in RED color, indicating the best solution. Your moves are displayed in BLUE color on the same map, making it easy to compare. Your performance is calculated based on how many moves you made compared to the best moves. This is represented as a score:

Performance = (Best Moves / Your Moves) × 100%

For example, if the best path took 30 moves and you took 40 moves, your performance would be:

Performance = (30 / 40) × 100% = 75%

### 2. Maze Generation

When the game starts, a random maze is created on the screen. The maze consists of several blocks connected in a grid, with some paths open and others blocked. To ensure there is always at least one path to the exit, the game uses a special algorithm called "union-find" to connect different parts of the maze.

The algorithm starts with every block isolated and randomly connects adjacent blocks by "breaking" walls between them. It continues to connect blocks in this way until there is a guaranteed path from the starting point to the exit. This ensures that every maze generated has at least one continuous path from the beginning to the end, regardless of how many paths are blocked.

This method guarantees that the maze is both random and solvable, providing a challenging but fair experience every time you play.

### 3. Finding the Shortest Path

The game uses a special algorithm called Breadth-First Search (BFS) to calculate the shortest path from start to end. BFS is a method that explores all possible paths layer by layer, starting from the initial position. It checks each neighboring block, one step at a time, and keeps track of all the possible routes. When it reaches the exit, it backtracks to find the path that took the fewest steps. This ensures that the path found is the shortest possible route through the maze.

Once the shortest path is determined, it is highlighted on the maze in a distinct color (e.g., red) to show you the most efficient way to reach the exit. This highlighted path is known as the "Best Path," as it represents the minimum number of moves required to solve the maze.