BACK TO TRAIL LEVEL 6 // TREMAUX SOLVER
The Final Challenge

LEVEL 6: TREMAUX SOLVER

1. What is it?

The loop-solving Trémaux mapping algorithm.

2. Why do we need it?

Simple robots (using standard Left-Hand Rule) get trapped in infinite circles when running into loop tracks. Trémaux counts node arrivals to flag loop gates, closes the redundant path, executes a U-turn, and escapes the loop.

3. The Challenge

Select and compare Left-Hand Rule (gets stuck) and Tremaux Solver (escapes loop) on the full grid maze track simulator.

Choose Solving Method

Loop Candidate Strikes: 0
Path Log:
RESET

Modified Trémaux Decision Loop

int8_t matchID = findMatchingJunction(arrTime, pattern, arrDir);
 
 if (matchID == -1) {
     // New junction: register and apply standard Tremaux rules
     jID = registerJunction(arrTime, pattern, arrDir);
     junctions[jID].edgeMarks[arrDir]++;
     dir = tremauxSelectTurn(jID, found_left, found_straight, found_right);
 } else if (junctions[matchID].loopCandidate == 0) {
     // First Strike: Flag as candidate but treat as new to verify timing stability
     junctions[matchID].loopCandidate = 1;
     jID = registerJunction(arrTime, pattern, arrDir);
     junctions[jID].edgeMarks[arrDir]++;
     dir = tremauxSelectTurn(jID, found_left, found_straight, found_right);
 } else {
     // Confirmed Loop (Second Strike): Force U-turn and collapse path
     jID = matchID;
     junctions[jID].edgeMarks[arrDir] = 2; // Close path
     dir = 'B'; // U-turn
 }