How do DP and CC change in Piet?

Posted by Paul Butcher on Stack Overflow See other posts from Stack Overflow or by Paul Butcher
Published on 2010-04-29T10:05:40Z Indexed on 2010/04/29 16:37 UTC
Read the original article Hit count: 525

Filed under:
|

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: http://www.dangermouse.net/esoteric/piet/fibbig1.gif (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:

  1. Attempt (and fail) to leave the block by going off the edge at (0,4),
  2. Toggle CC to RIGHT,
  3. Attempt (and fail) to leave the block by going off the edge at (0,2).
  4. Rotate DP to UP,
  5. Attempt (and succeed) to leave the block at (1,2) by entering the white block at (1,1)

The behaviour indicated by the trace seems to be that DP gets rotated all the way, leaving CC at LEFT.

What have I misunderstood?

© Stack Overflow or respective owner

Related posts about piet

  • How do DP and CC change in Piet?

    as seen on Stack Overflow - Search for 'Stack Overflow'
    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… >>> More

  • Performance problem with an Intel Wireless 5100

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I just installed 12.04 on a HP Elitebook 2530p. The performance with wireless connection to an Eminem 4551 is very bad. Wired connection just works great. If I connect to my router (Eminent 4551) wired I have a good performance accessing internet pages with Firefox. When I try to access the same… >>> More

  • ORACLE UNIVERSITY

    as seen on Oracle Blogs - Search for 'Oracle Blogs'
    Expert Seminar in Dubai: How to choose your High-Availability solutions with Piet de Visser Oracle University's Expert Seminars are delivered by the best Oracle Gurus in the industry from all over the world. These unique and informative seminars are designed to provide you with… >>> More

  • HAML on Rails 3 doesn`t work

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hey there, i have tried to render some files with HAML in Rails 3. But HAMl doesn`t work. My testfiles have the extension .html.haml. In the GEMFile i have written gem 'haml' and executed the bundle install When i call my testapp i become an error like this: Template is missing Missing template… >>> More

Related posts about esoteric-languages