Talk:Zetaplex

From Esolang
Jump to navigation Jump to search

Hey, was just wondering if anyone has tried writing a program with this? If so, would you like to share? poiuy_qwert 14:33, 26 September 2008 (UTC)

Sorry, I haven't. But the programs you've made look pretty impressive alone, already. :) --Keymaker 07:32, 27 September 2008 (UTC)
I agree. However, could you double-check your zetaplex interpreter, please? The link appears to be broken. Thanks, Okohokonu 21:14, 30 March 2009 (UTC)
Hmm the host I used sucks for downloads, if anyone has a better place to upload it i'll do that. Just thought I would also mention that I'm working on a new interpreter in C++ (for Mac and Windows using Qt). poiuy_qwert 19:57, 25 September 2009 (UTC)

Updates

Well as mentioned above I'm making an updated interpreter, but I did not mention that there is going to be a little revision of the specification. One thing that will see some nice improvements is the drawing capabilities, which should now surpass Gammaplex (but still not Deltaplex). Here is an example of the new interpreter (running on Mac), using the simple code:

60#300#3s*0#0s+255#0#0#255s+100s+50s+5s+5#3s*14DpDrFe

Which produces:

I plan to update all programs eventually, and my goal for a new program is a nice snake game. Anyway, back to it ;) poiuy_qwert 16:39, 13 October 2009 (UTC)

Tic-Tac-Toe description

mD"eot-cat-ciT"DT194syDR-1#64s+195#130Dbsfs-sfDbDr5sS31'AhT8sS'@8sYyny+s+Fn
"([^@])..\1..\1"Srs+"([^@])...\1...\1|..([^@]).\2.\2.."Srs+"([^@])\1\1......|...([^@])\2\2...|......([^@])\3\3"Sr8sSFn
>tsF?\2sD
     \2sDtc65sfM_MIsf65sfM_MIhXhYHTHY3M*HXM+Misy2M+lg'@F=\2sDFp
 HT'AF=\                          \                      \ls
       \0sSsZHY65M*MiHX65M*Mis+Fn \0sSsZHY65M*32M+HX65M*32M+Dp'AhT\
 sZHY65M*62M+HX65M*62M+Dl61sfM-s-61M+Dl'BhT                       >DrFn
 8sSSys+8Scs-RmF?\Sy10sS8Sc8sSRmF?\Sy11sS8Sc8sSRmF?\Fn
^                >                >                >Fn
 ts2sDF?\
/       \ycDr8sSsZ'@8sY

Here is a walkthrough of the Tic-Tac-Toe game (shown above). You don't need to know everything about Zetaplex to follow the explanations, but basic knowledge and a understanding of the way graphics are drawn is recommended.

"eot-cat-ciT"DT

Set the window title wth DT command.

194syDR

Put 194 on the stack, duplicate it with sy, then set the window size to (194,194) with DR

-1#64s+195#130Db

Draw a box with Db, where the topleft corner is at (-1,64) and bottom right at (195,130), esentially drawing two lines from left to right

sfs-sfDbDr

Switch the x and y coordinates for both the topleft and bottom right with sf, then draw a box with Db from (64,-1) to (130,195), esentially drawing two lines from top to bottom, then refresh the screen with Dr

5sS31'AhT

Go to the fifth stack and put 31 on it (this is the radius of the O when drawn), then set variable T to the ASCII value of A with 'AhT (this is the Turn variable. Player 1 is represnted by 'A, player two is 'B, and a box thats empty is '@)

8sS'@8sY

Go to the eigth stack, put the ASCII value of @ on it, then duplicate that 8 times with 8sY. This initializes the game board to be empty

yny+s+Fn

Create a new layer with yn then go to it with y+ (this lets me reset the game by just clearing that layer and not having to redraw the board), then go to the next stack with s+ and then next line with Fn

"([^@])..\1..\1"Srs+"([^@])...\1...\1|..([^@]).\2.\2.."Srs+"([^@])\1\1......|...([^@])\2\2...|......([^@])\3\3"Sr8sSFn

This loads regex strings into the stacks above the game board, which are used to check if someone has won. Once thats done it goes back to the board stack with 8sS and goes to the next line with Fn

>tsF?\2sD
     \2sD

This is the main input loop, it gets the pressed states of the mouse buttons onto the stack with ts, then checks if the left button is pressed with F?, if not it jumps the \, deletes the pressed states for middle and right buttons with 2sD, then wraps back to the beginning. If the left button is pressed it hits both \'s and once again deletes the other two pressed states, but continues

tc65sfM_MIsf65sfM_MIhXhY

Gets the X and Y coordinates of the mouse with tc, and transforms them into box coordinates ((0-2,0-2) instead of (0-194,0-194)). First it puts 65 on the stack, then swaps the top two values with sf (which are 65 and the X value of the mouse), then M_ divides the X value by 65, MI truncates the decimal, then that value and the Y value are swapped so the same can be done to the Y. Once thats all done it sets the values to variables X and Y with hXhY.

HTHY3M*HXM+Mi

Get who's turn it is with HT, then get the clicked box's Y value with HY, multiply it by 3 with 3M*, adds the boxes X value to it with HXM+, then increase it by 1 with Mi. This transforms the X,Y into an index on the board

sy2M+lg'@F=\2sDFp
           \ls

Duplicates the board index for the clicked box with sy, then adds two to it with 2M+ (since we still have the Turn and other Index values on the top of the board stack, the index is offset by 2), it then checks if that box is empty by getting the value on the board with lg, then comparing it to the ASCII of @ with '@F=. If the spot isn't empty it jumps the \, deletes the box index and Turn value with 2sD, then goes to the beginning of the previous line, back into the input loop. If it is empty, it places the current Turn value into the box with ls, then wraps back to the beginning of the line.

HT'AF=\                          \

To decide whether to draw an X or an O, this gets the Turn value back on the stack with HT, checks if it equals the ASCII of A with 'AF=, if it does hits the \, if not it jumps it and hits the next \

Draw X for P1 ('A)

\0sSsZHY65M*MiHX65M*Mis+Fn

Go to stack 0 with 0sS, clear the stack with sZ, get the clicked box's Y with HY and multiply it by 65 and increase by 1 with 65M*Mi, then do the same to its X value. This calculates the x,y of the topleft of the X to draw in the box. Finally go to the next stack with s+ and the next line with Fn

sZHY65M*62M+HX65M*62M+Dl

Clear the stack with sZ, get the clicked box's Y with HY and multply it by 65 and add 62 with 65M*62M+, then do the same to its Y value. This calculates the x,y of the bottom right of the X to draw in the box, then it draws the line from topleft to bottom right with Dl.

61sfM-s-61M+Dl'BhT                       >DrFn

Subtract 61 from the Y value of the bottom right with 61sfM- to get the x,y of the top right, go to the previous stack with s-, then add 61 to the Y value of the topleft with 61M+ to get the x,y of the bottom left, and draws the line from bottom left to top right with Dl. Finally it changes the current turn to player 2 with BhT, then redraws the screen with Dr and goes to the next line with Fn'. This is also where the logic joins again from where it split between player 1 and player 2's turns.

Draw O for P2 ('B)

\0sSsZHY65M*32M+HX65M*32M+Dp'AhT\
                                >DrFn

Go to stack 0 with 0sS, clear the stack with sZ, get the clicked box's Y with HY and multiply it with 65 and add 32 to it with 65M*32M+, then do the same with the X value. This calculates the x,y of the center of the O to draw in the box, which is drawn with Dp. Finally it changes the current turn to player 1 with 'AhT, then redraws the screen with Dr and goes to the next line with Fn. This is also where the logic joins again from where it split between player 1 and player 2's turns.

Rejoin

(Once doing the player specific drawing of X or O, the logic rejoins)

 8sSSys+8Scs-RmF?\Sy10sS8Sc8sSRmF?\Sy11sS8Sc8sSRmF?\Fn
^                >                >                >Fn

Go to the board stack with 8sS, copy the whole board with Sy, go up to the next stack with s+, then copy the regex string to the board stack with 8Sc. Go back to the board stack with s- and check if the board matches the regex with RmF?, if it does it hits the \ then the > and goes on to the next line with Fn, if not it checks the board against the next two regex strings the same way. If none of the regex strings match the board noone has won, so it goes to the next line with Fn where it hits the ^ and goes back up to the input loop

 ts2sDF?\
/       \ycDr8sSsZ'@8sY

This is only reached if someone won. It is a sub input loop, ts gets the pressed state of the mouse buttons, 2sD deletes the states for the left and middle buttons, then it checks if the right button is pressed with F?, if not it jumps the \ and keeps checking. If the right click button is down it hits both \'s then clears the current layer with yc, redraws the screen with Dr, goes to the board stack and clears it with 8sSsZ, then creates a new empty board with '@8sY, finally wrapping to the beginning of the line, hitting the / and going back up to the main input loop. End

Logic Flow Image

Here is an image to visually show the flow of the program.