According to the specification,
Black colour blocks and the edges of the program restrict program flow. If the Piet interpreter attempts to move into a black block or off an edge, it is stopped and the CC is toggled. The interpreter then attempts to move from its current block again. If it fails a second time, the DP is moved clockwise one step. These attempts are repeated, with the CC and DP being changed between alternate attempts. If after eight attempts the interpreter cannot leave its current colour block, there is no way out and the program terminates.
Unless I'm reading it incorrectly, this is at odds with the behaviour of the Fibonacci sequence example here:
(from: http://www.dangermouse.net/esoteric/piet/samples.html)
Specifically, why does the DP turn left at (0,3) ((0,0) being (top, left)) when it hits the left edge? At this point, both DP and CC are LEFT, so, by my reading, the sequence should then be:
The behaviour indicated by the trace seems to be that DP gets rotated all the way, leaving CC at LEFT.
What have I misunderstood?
Your analysis seems correct; the sample is buggy. The white block at (1,1) should be black. You can verify this by grabbing the sample image and executing it.
Note that at least three of the interpreters linked from DMM's page are buggy - Marc Majcher's is marked as such, Sylvain Tintillier's traverses and outputs correctly but switches the meaning of in and inn from the spec (this is a bug-free version), and PietDev incorrectly traverses colour blocks.
EDIT: other white blocks probably also need to be black, e.g. the block at (6,3).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With