The main challenge with the crossed section is that when the robot passes it, it registers turns in both directions. Later, when the robot encounters an actual turn, it may choose the wrong path since there are two registered turns. To address this, we add one variable to help the robot remember the last detected turn. This allows the robot to prioritize the most recent registered turn.
We’ll call this variable "Last Detected Turn." Instead of directly calling the turn functions in the program, we’ll use a "Prioritize Turning" function, which will choose the direction to turn based on this variable.
For readability, we haven’t used this variable to verify if a turn exists in a particular direction, as doing so would add complexity, even though it would reduce the number of command blocks. We mention this to show there are ways to enhance the program, and you should focus on understanding the method used here.