I'm currently fascinated with the Piet esoteric programming language. It's a two-dimensional language that relies on the changes in hue and in value. I have a few sample programs here that I'm pretty proud to show off (also I needed a break from K&R making me feel stupid).
Check out the trace/
directory if you want to see how these programs execute.
This program is a Hello, world!
type program that prints out Hi
(with a new
line)
This program is a Hello, world!
program. If this is your first time looking
at Piet, take a look at hello-trace.png
to see what the program does. It will
give you a pretty good idea of what's going on under the hood without having
to worry about the DP or CC.
This is a "guessing game" that asks the user for input and displays a win message as well as a lose message. Due to a lack of space at the end, I had to do some trickery as well as fighting with the codel chooser to get both messages to share a newline.
This is a fizzbuzz program that I made by hand. The only other fizzbuzz I've seen is one that was made with a Piet program generator. I think that's cheating, but that would have been really nice to have on this one.
I set up the modulus stuff first, then added incrementation using the concepts from the while and comparison constructs I discovered. That single sentence encompassed at least 6 hours of painfully debugging, but it's worth it (I guess)
I would be lying if I told you writing these programs was painless. I spent at least three hours on the guessing game. Anyway:
Because these programs aren't text files, I obviously couldn't use vim. Instead, I used Gimp to export as .png/.ppm files. I also had to install a custom palette for Gimp so I wouldn't mess up the colors.
There's a list of interperetrs on Piet's website.
The one I used was npiet
. I downloaded the source code and installed all the
missing headers I needed to build it with png support. (I might convert the
programs to .ppm format so those without the png version can run them)
I didn't want to rely on some website to run my programs, so I used the npiet
build I had (with png support) and ran them with -tpic. I just opened them in
an image viewer and looked at where I went wrong. See trace/
for some examples
of running a program with the -tpic flag.
Piet's website - http://www.dangermouse.net/esoteric/piet.html
npiet's website - http://www.bertnase.de/npiet/
Short tutorial - http://homepages.vub.ac.be/~diddesen/piet/index.html
Gimp palette - http://copb-phoenix.deviantart.com/art/Piet-483311648