According to specification,
The black blocks and edges of the program limit the flow of the program. If the Piet interpreter tries to move to the black block or from the edge, it stops and the CC switches. Then the interpreter tries again to move from its current block. If it does not fire a second time, DP moves clockwise one step. These attempts are repeated when CC and DP change between alternating attempts. If after eight attempts the interpreter cannot leave its current color block, there is no way out and the program terminates.
If I do not read it incorrectly, this contradicts the behavior of the example Fibonacci sequence: http://www.dangermouse.net/esoteric/piet/fibbig1.gif (from: http://www.dangermouse.net/esoteric/piet/samples. html )
In particular, why does DP turn left (0.3) ((0.0) (top, left)) when it hits the left edge? At this stage, both DP and CC are LEFT, so, in my opinion, the sequence should be as follows:
- An attempt (and failure) to exit the block, leaving the edge at (0.4),
- Toggle CC to the right,
- An attempt (and failure) to exit the block, leaving the edge at (0.2).
- Turn DP to UP,
- An attempt (and success) to leave a block at (1,2) by entering a white block at (1,1)
The behavior shown by the trace seems to be that the DP rotates completely, leaving CC on the LEFT.
What did I misunderstand?