Piet-Q is a modification of the esoteric programming language named Piet by David Morgan-Mar created by poiuy_qwert. Piet is a 2D language and uses colors in a bitmap as the commands to be executed. Similarly, Piet-Q uses a bitmap as the program, but has a different way of executing commands. The main difference is that in Piet commands are called by the difference in the HUE from one color to the next. In Piet-Q the color of the pixel is split into its Red, Green, and Blue (RGB) parts. The command is the integer for the Red section of the color, and the Blue and Green can be parameters for that command.
- Command Pointer (CP): The pointer to the coordinates of the current executing command.
- Directional Pointer (DP): The direction the CP will move after command execution. The DP can be 0, 1, 2, or 3 meaning Right, Down, Left, Up respectively.
- Stack: There are 256 stacks named 0-255 which can store an unlimited (not taking into account the interpreter's limitations) amount of integers.
- Item: One of the integers in a stack which are referenced by an integer, 0 being the first item. An empty or non-existant item is 0.
- R: The Red section of the current color, which is also the command.
- G: The Green section of the current color, which can also be the first parameter for a command.
- B: The Blue section of the current color, which can also be the second parameter for a command.
Piet-Q programs are written inside bitmap files. The CP starts at the top left corner of the image which is coordinates (0,0). The program executes the command at the CP then moves the the next command depending on the DP. The program continues execution untill the CP is outside of the bitmap or the command at the CP is the End Program command.
|1||2||Prints the integer in item B from stack G.|
|2||2||Prints the character with ASCII value in item B from stack G.|
|3||1||Clear stack G.|
|4||2||Copy stack B to stack G.|
|5||2||Append integer B to stack G.|
|6||2||Append the length of stack B to stack G.|
|7||2||Shift stack G down B times (bottom comes to top, top moves down).|
|8||2||Shift stack G up B times (top goes to bottom, bottom moves up).|
|9||2||Delete item B from stack G.|
|10||2||If item 0 in stack G is equal to item 0 in stack B, make a right turn, else, make a left turn.|
|11||2||If item 0 in stack G is greater than item 0 in stack B, make a right turn, else, make a left turn.|
|12||2||If item 0 in stack G is less than item 0 in stack B, make a right turn, else, make a left turn.|
|13||2||If item 0 in stack G is not equal to item 0 in stack B, make a right turn, else, make a left turn.|
|14||2||Jump to command at coordinates (G,B) and execute it.|
|15||2||Jump to command at coordinates (item 0 from stack G,item 0 from stack B) and execute it.|
|16||1||Change direction to G. If G is greater than 3 it loops back to 0. For example: 4, 8, and 16 are all Right.|
|17||1||Get an integer from the user and append it to stack G.|
|18||2||Get a string with a max length of B and append its ASCII values to stack G.|
|19||2||Taking all values from stack G, change the command at coordinates (item 0,item 1) to an (R,G,B) of (item 2,item 3,item 4)|
|20||1||Put the Y value then the X value of the current command on stack G (so X will be item 0)|
|21||2||Add item 0 in stack B to item 0 in stack G|
|22||2||Subtract item 0 in stack B from item 0 in stack G|
An interpreter for Piet-Q can be found Here, created by the original author poiuy_qwert.
This is a basic Hello World program in Piet-Q. It outputs "Hello, World!" to the screen.