whitespace
|
|
« Reply #60 on: November 30, 2008, 12:51:11 AM » |
|
<link to this thread> sounds so cool. I'm starting to write an interpreter in java right now
done damn. I just read the timestamp and realized that it is 2am. Well here it is. There is a //TODO for more than binary field states involving colors and such. And maybe I'll add a better CLI. But first things first. Good night! Great! But can you tell if/how it works under windows? There's also javascript-interpreter now: http://www.formauri.es/personal/pgimeno/temp/esoteric/paintfuck/paintfuck.phpSame person wrote a beautiful program: LANGTON'S ANT PAINTFUCK PROGRAM BY PEDRO GIMENO
CELL LAYOUT:
XN SW
X IS THE TARGET SUBCELL. AT MOST ONE OF N, S AND W WILL BE 1 WHEN WE COME FROM THAT DIRECTION. IF WE COME FROM THE EAST THEN ALL OF THEM WILL BE ZEROS.
*[* FOREVER:
AT THIS LOOP LEVEL, N, S AND W WILL ALWAYS BE 0 ON ALL CELLS BUT THE CURRENT.
WE START ON THE "N" SUBCELL OF THE CELL WEST OF X. INSIDE EACH CONDITION WE'LL USE ALL THREE INITIALLY ZERO FLAGS FROM THE CELL WEST OF X AS AUXILIARY STORAGE. WE'LL CALL THESE "LN", "LS" AND "LW".
NORTH? ee[ RESET "N" FLAG: * GO TO TARGET: w COPY TARGET TO "LW" BECAUSE THE CHECK BELOW IS DESTRUCTIVE. THE COPY ITSELF IS DESTRUCTIVE SO WE MAKE TWO COPIES SIMULTANEOUSLY (THE OTHER ONE IN "LN"). [w*s*ne*] GO TO THE "LN" COPY AND TOGGLE IT AS PER LANGTON'S ANT RULES: w* NOW COPY "LN" BACK INTO TARGET. [e*w*] GO TO "LW" TO CHECK: s WAS TARGET = 1 (BEFORE TOGGLING)? [* (WE RESET "LW" HERE) YES-MOVE RIGHT (EAST) AND MARK THAT WE COME FROM EAST, SETTING "LN" TO SIGNAL WE'RE DONE. TO MARK THAT WE COME FROM EAST, WE JUST SET NO FLAG. een*s ] GO TO "LN" TO CHECK FOR DONE. n
DONE? FORGET ABOUT TURNING RIGHT IF SO. *[* NOT DONE, SO THE TARGET CELL WAS = 0. IT'S ALREADY TOGGLED SO ALL THAT IS LEFT IS TO MOVE LEFT (WHICH IS WEST, AS WE CAME FROM NORTH). WE HAVE TO SIGNAL THAT WE'LL COME FROM WEST. s*nww ] RETURN TO WHERE THE CONDITION REQUIRES US TO BE (THE "N" FLAG). ee ] RETURN TO THE "LN" SUBCELL. ww
EAST? THIS IS THE HARDEST TO TEST AS ALL MUST BE ZERO. TO CHECK IT, WE DO THE "NOR" OPERATION ON ALL THREE, STORING THE RESULT IN THE "LN" FLAG.
SET "LN" TO ONE: *
MAKE TWO COPIES OF "N" INTO "LS" AND "LW" (THIS DESTROYS IT). ee[wws*w*enee*] COPY "LS" BACK TO "N". THIS DESTROYS "LS" BUT WE STILL HAVE A COPY IN "LW". wwsw[enee*wwsw*] (DESTRUCTIVE) CHECK IF "LW" IS ONE. IF SO, CLEAR THE "LN" FLAG. e[*n[*]s]
COPY "W" USING THE ABOVE TWO STEPS: ee[ww*w*eee*]www[*eee*www] SAME AS BEFORE: e[*n[*]s]
COPY "S" THE SAME WAY: e[w*w*ee*]ww[*ee*ww] AGAIN: e[*n[*]s]
NOW WE HAVE "LN" SET TO 1 IF WE GO EAST. CHECK IT. n [* ALSO RESET IT. FINALLY! WE COME FROM EAST. NOW REPEAT THE STEPS ABOVE.
MAKE A COPY OF TARGET INTO "LW" AND TOGGLE TARGET: e[w*s*ne*]w*[e*w*] s [* WAS TARGET = 1? WE COME FROM EAST, SO TURN RIGHT = SOUTH. ALSO SET "LN"=DONE. s*es*w ] DONE? FORGET ABOUT TURNING RIGHT IF SO. n*[* NOT DONE, SO THE TARGET WAS = 0. MOVE LEFT (NORTH) AND MARK IT. eenn* GO BACK TO THE "LN" FLAG. ww ] ]
EQUIVALENT FOR WEST: ees[* nw[w*s*ne*]w*[e*w*] s[* WE COME FROM WEST, SO RIGHT = NORTH. nnn*ee*sww ] n*[* LEFT = SOUTH. esss*nw ] ees ]nww
NOW SOUTH: es[* n[w*s*ne*]w*[e*w*] s[ AS A SPECIAL CASE, WE DON'T RESET "LW" BECAUSE IT BECOMES THE NEW "W".
WE COME FROM SOUTH, SO RIGHT = WEST. wwn*s ] n*[* LEFT = EAST. ee ] es ]nw
*]
Someone decided to do 110-rule too: ww*ees* [ e*[* w ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnne ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnne ss*nnn[ss*s*s*nnnn*]ssss[*nnnn*ssss]nnnw
sw [*e[*es[*nnw*ess]nw] s[*en[*nw*es]sw]nw] s [*en[*n*s] s[*en[*nw*es]sw]w] n[*]e[*]e[*]s[*]w[*]w[*] nne
e*]s* ] IRC-log of yesterday on the esoteric-channel: http://tunes.org/~nef/logs/esoteric/08.11.29+I've started paintfuck topic at esolang wiki: http://esolangs.org/wiki/Paintfuck
|
|
« Last Edit: November 30, 2008, 12:57:41 AM by whitespace »
|
Logged
|
|
|
|
Hideous
|
|
« Reply #61 on: November 30, 2008, 01:46:28 AM » |
|
I told a friend about this language the other day, and he thought it looked lame.
Then you entered #esoteric (or whatever the name was), and now he's hooked.
|
|
|
Logged
|
|
|
|
whitespace
|
|
« Reply #62 on: November 30, 2008, 06:07:09 AM » |
|
I told a friend about this language the other day, and he thought it looked lame.
Then you entered #esoteric (or whatever the name was), and now he's hooked.
Yeah those esolang-people are pretty grumpy in the beginning
|
|
|
Logged
|
|
|
|
Decipher
Guest
|
|
« Reply #63 on: November 30, 2008, 07:52:27 AM » |
|
Okay so here's the interpreter written in C++. Simple: paintfuck < script-file > This is quite late because I had a few issues to take care of, so I'm genuinely sorry for being late. Other than that, this is not the last version! In fact, I'll keep developing it. So expect a new version soon . I asked whitespace for permission to maintain a webpage for paintfuck, and it will soon be located at http://beskrajnost.com/paintfuck. So, this is just an interpreter for now, but I'll make sure it becomes a cross-platform IDE for paintfuck. You can get the Win32 binaries from here. Linux 32/64 is comming, as well as an OS X port. Enjoy.
|
|
|
Logged
|
|
|
|
whitespace
|
|
« Reply #64 on: November 30, 2008, 08:07:36 AM » |
|
Okay so here's the interpreter written in C++. Simple: paintfuck < script-file > This is quite late because I had a few issues to take care of, so I'm genuinely sorry for being late. Other than that, this is not the last version! In fact, I'll keep developing it. So expect a new version soon . I asked whitespace for permission to maintain a webpage for paintfuck, and it will soon be located at http://beskrajnost.com/paintfuck. So, this is just an interpreter for now, but I'll make sure it becomes a cross-platform IDE for paintfuck. You can get the Win32 binaries from here. Linux 32/64 is comming, as well as an OS X port. Enjoy. Cool, I like to drag and drop file instead of commandprompt Looks nice, looks fast, but when I inserted a neverending program it went mad, took all my cpu and terminated.
|
|
|
Logged
|
|
|
|
Decipher
Guest
|
|
« Reply #65 on: November 30, 2008, 08:39:02 AM » |
|
but when I inserted a neverending program it went mad, took all my cpu and terminated. That's a feature, not a bug! Don't worry, in the next version I'll add the debugging features, there I can also add infinite loop detection
|
|
|
Logged
|
|
|
|
whitespace
|
|
« Reply #66 on: November 30, 2008, 08:49:28 AM » |
|
Ok great!
fyi: There's a lot of discussion on the language going on at irc://freenode/esoteric
|
|
|
Logged
|
|
|
|
increpare
Guest
|
|
« Reply #67 on: November 30, 2008, 08:51:42 AM » |
|
there I can also add infinite loop detection that sounds like a halting problem to me...but...good luck trying!
|
|
|
Logged
|
|
|
|
Decipher
Guest
|
|
« Reply #68 on: November 30, 2008, 09:17:39 AM » |
|
increpare: I can parse the code beforehand to detect logical infinite loops. I think they occur as a certain pattern in the code. Edit: After I talked furthermore with ehird from #esoteric, it's a saner idea to leave the crash-course as is. so, as I originally said, it's a feature not a bug . Also forgot to tell, pressing 'p' takes a screenshot in the original interpreter I coded, that isn't present in the obfuscated one. Oh by the way, lookies, what I have done: So, I made myself a delightful little challenge, my idea was to code an interpreter codeblock under 30 minutes, and as Hideous observed it took 19:35 minutes to create this from scratch . #include<SDL/SDL.h>/*! <~~~~~~~~~~~ Paintfucker :*: by Decipher ~~~~~~~~~~~> !*/ SDL_Surface*a;SDL_Rect b={0,0,5,5};int g,k;int c(int x,int y){return*((int*)a-> pixels+x+y*200);};int main(int d, char**e){char*h,*i;if(d<2)return 0;FILE*f= fopen(e[1],"r");fseek(f,0,2);g=ftell(f);fseek(f,0,0);h=malloc(g);i=h;fread(h,g,1 ,f);fclose(f);a=SDL_SetVideoMode(200,200,32,0);SDL_FillRect(a,0,0);SDL_Event j; while(1){if(SDL_PollEvent(&j)&&j.key.keysym.sym==27)break;else if(i!=h+g){switch (*i){case'e':b.x+=5;if(b.x>195)b.x=0;break;case'w':b.x-=5;if(b.x<0)b.x=195;break ;case's':b.y+=5;if(b.y>195)b.y=0;break;case'n':b.y-=5;if(b.y<0)b.y=195;break; case'*':if(!c(b.x+1,b.y+1))SDL_FillRect(a,&b,0xFFFFFFFF);else SDL_FillRect(a,&b, 0);break;case'[':if(!c(b.x+1,b.y+1)){k = 0;while(i<h+g){if(*i=='[')++k;else if(* i==']')if(!--k)break;++i;}}break;case']':k=0;while(i>=h){if(*i==']')++k;else if( *i=='[')if(!--k){--i;break;}--i;}break;}++i;}SDL_Flip(a);}free(h);return 0;}
|
|
« Last Edit: November 30, 2008, 10:03:54 AM by Decipher »
|
Logged
|
|
|
|
Zaphos
Guest
|
|
« Reply #69 on: November 30, 2008, 02:37:53 PM » |
|
there I can also add infinite loop detection that sounds like a halting problem to me...but...good luck trying! The rather limited memory of paintfuck might make it possible to analyze? Actually, if you just run the program and remember every state (including program counter in state) then when you get to a repeat state you know you're in an infinite loop? Assuming your own computer has infinite memory*, I think this should work ... not very practical, though. * actually just w*h*program_length bits, and it could probably compress pretty well for most programs
|
|
« Last Edit: November 30, 2008, 11:55:12 PM by Zaphos »
|
Logged
|
|
|
|
george
|
|
« Reply #70 on: November 30, 2008, 03:01:24 PM » |
|
I quite like this one: *[e*]*w[s*]*n[w*]*e[n*]*[es*]*s[sw*]* [sww[nne*]*]
|
|
|
Logged
|
|
|
|
Loren Schmidt
|
|
« Reply #71 on: November 30, 2008, 08:08:54 PM » |
|
I love the binary counter and the Langston's Ant programs.
You know, I've never been big on rigidly defining what a 'game' is... I think semi-autonomous systems like this and Conway's Life really have every bit as much to offer as more conventional fare.
|
|
|
Logged
|
|
|
|
whitespace
|
|
« Reply #72 on: December 01, 2008, 08:57:30 AM » |
|
|
|
|
Logged
|
|
|
|
increpare
Guest
|
|
« Reply #73 on: December 01, 2008, 10:35:10 AM » |
|
Cool
|
|
|
Logged
|
|
|
|
Kneecaps
|
|
« Reply #74 on: December 02, 2008, 03:04:15 PM » |
|
|
|
|
Logged
|
|
|
|
Loren Schmidt
|
|
« Reply #75 on: December 02, 2008, 04:37:23 PM » |
|
Oh, wow. I still don't know how he managed to store all the scratch data!
This is kind of over my head, but is he storing the neighboring cell count in binary? That seems like it might fit, and be easier to do conditional operations on.
Very neat.
|
|
|
Logged
|
|
|
|
increpare
Guest
|
|
« Reply #76 on: December 02, 2008, 04:45:22 PM » |
|
but is he storing the neighboring cell count in binary?
that's what the source seems to indicate, yup
|
|
|
Logged
|
|
|
|
|