A thief has snuck his way into the wizard's castle. After traversing a plethora of magical traps and illusory walls, he finally spies the wizard's hidden stash of gems beyond the end of a long corridor. He hastily runs toward it, realizing only a moment too late that he has fallen into another trap.
As soon as the thief enters the corridor, a magical flame ignites behind him, and the corridor is divided into segments by thick walls of fog. A message from the wizard appears on the wall of the corridor, lit with a magical glow:
This corridor has 10 segments, each identical and symmetrical in appearance. The first has no special properties, but some of the remaining 9 will turn you around as soon as you enter them. You will feel nothing, but the way forward will become the way back. If you blindly continue, you will end up back where you started. Should you move between segments more than 30 times, you will be trapped in an alternate dimension.
None of the thief's navigational aids are working, and the corridor resists any attempt to mark it. How can the thief guarantee his escape from the labyrinth?