Posted July 10, 2016
high rated
EDIT on 29th June 2017:
A new version of this is available:
https://www.gog.com/forum/general/my_new_and_improved_gogcom_brainfck_quine_v2
https://www.youtube.com/watch?v=ob2zLvE23Lo
http://www.zbalbous.com/bfgogquine.html
Original version below:
-------------------------------------------------------------------------------------
So I was looking for ideas for my next esoteric challenge, and I thought maybe I could do something with quines. Unfortunately I couldn't come up with any original and interesting ideas of hiding the game key (ones that I didn't already use before in my previous two challenges). I thought a bit of creating a quine with GOG.com logo in it and the game key hidden somewhere, but again the key-hiding puzzle itself was either too easy or too complicated or just boring.
While looking around I stumbled upon a globe quine done in Ruby by Yusuke Endoh, and I thought it would be a cool idea to do something like that in brainfuck. So after a bit of work I finally managed to complete it. Here is my first attempt. Unfortunately the code is a bit (or a lot) too verbose.
http://www.zbalbous.com/bfgogquine.html
It's brainfuck code that prints itself, except that the globe part of the code gets rotated by 1/50th of a circle. After 50 iterations you get the original code. So it's an iterative-quine that works like: code0 -> code1 -> code2 -> ... -> code48 -> code49 -> code0 -> etc.
To visualise it, here is a youtube video that's basically a slideshow of the codes put together. In essence every frame is valid brainfuck code that outputs the next frame.
https://www.youtube.com/watch?v=ws-bRLdMJrs
As I said, initially I was thinking of putting a GOG.com logo in the code. After I decided to create a globe instead, the logo's fate was to be shrunk and put somewhere in the south Atlantic.
While working on it, I thought it would be an interesting challenge to add another restriction to it. As those familiar with brainfuck know, a period (.) is used for outputting a character at the data pointer. So my restriction was:
_The code should contain only one period.
As you can see, my code indeed does contain only one, neatly hidden in my email.
If you want to run the code, note that:
_It uses 8-bit size cells (which I believe is the usual implementation).
_You need a memomry size of 170,000 (!). 165317 to be exact. Note that most brainfuck implementations use a default of 30,000 memory size, so make sure change that, else the code won't run properly.
_It's very slow. I never optimized it for speed or memory. Far from it in fact; I tried to make the code itself small (whether I suceeded is a different story), so I'd often be content with taking a huge performance hit if it meant shaving off a few bytes of the code here or there.
You can try running the code in this online interpreter
https://copy.sh/brainfuck/
Remember to change memory size to 170000 first. Or use Dynamic memory but that will make it even slower. It runs about 3 minutes on my machine. Other online interpreters out there might not even run it. A better idea would be to look for faster interpreters (just remember about the memory). I used one writtern in C# that works by translating the brainfuck commands to their C equivalents.
Also, you will need a monospace font of course to see the output properly. Depending on what font you use the globe might be a bit stretched. I used Lucida console in the video.
You can download the raw source code here
http://www.zbalbous.com/bfgogquine.b
Just note that there are 255 characters per line, and at default font size and the usual screen resolution, most browsers would wrap it so you won't see it properly. Zoom out/decrease fot size to see it.
So that's it. Unfortunately this means that there won't be any esoteric challenge for the time being.
I'll come back to this when I have more time. I have a few ideas on how to make the code much smaller, but that would mean doing a lot of it back from scratch (and abandoning my 1-period-only rule). So I'll need to wait till I have more spare time.
Credits:
_A huge huge thank you to Yusuke Endoh's Qlobe for the idea and inspiration. Unfortunately I do not know Ruby, but his quine convinced me to try copy his idea in brainfuck.
http://mamememo.blogspot.ie/2010/09/qlobe.html
_Thanks to Erik Bosman's famous 410-byte quine.
A new version of this is available:
https://www.gog.com/forum/general/my_new_and_improved_gogcom_brainfck_quine_v2
https://www.youtube.com/watch?v=ob2zLvE23Lo
http://www.zbalbous.com/bfgogquine.html
Original version below:
-------------------------------------------------------------------------------------
So I was looking for ideas for my next esoteric challenge, and I thought maybe I could do something with quines. Unfortunately I couldn't come up with any original and interesting ideas of hiding the game key (ones that I didn't already use before in my previous two challenges). I thought a bit of creating a quine with GOG.com logo in it and the game key hidden somewhere, but again the key-hiding puzzle itself was either too easy or too complicated or just boring.
While looking around I stumbled upon a globe quine done in Ruby by Yusuke Endoh, and I thought it would be a cool idea to do something like that in brainfuck. So after a bit of work I finally managed to complete it. Here is my first attempt. Unfortunately the code is a bit (or a lot) too verbose.
http://www.zbalbous.com/bfgogquine.html
It's brainfuck code that prints itself, except that the globe part of the code gets rotated by 1/50th of a circle. After 50 iterations you get the original code. So it's an iterative-quine that works like: code0 -> code1 -> code2 -> ... -> code48 -> code49 -> code0 -> etc.
To visualise it, here is a youtube video that's basically a slideshow of the codes put together. In essence every frame is valid brainfuck code that outputs the next frame.
https://www.youtube.com/watch?v=ws-bRLdMJrs
As I said, initially I was thinking of putting a GOG.com logo in the code. After I decided to create a globe instead, the logo's fate was to be shrunk and put somewhere in the south Atlantic.
While working on it, I thought it would be an interesting challenge to add another restriction to it. As those familiar with brainfuck know, a period (.) is used for outputting a character at the data pointer. So my restriction was:
_The code should contain only one period.
As you can see, my code indeed does contain only one, neatly hidden in my email.
If you want to run the code, note that:
_It uses 8-bit size cells (which I believe is the usual implementation).
_You need a memomry size of 170,000 (!). 165317 to be exact. Note that most brainfuck implementations use a default of 30,000 memory size, so make sure change that, else the code won't run properly.
_It's very slow. I never optimized it for speed or memory. Far from it in fact; I tried to make the code itself small (whether I suceeded is a different story), so I'd often be content with taking a huge performance hit if it meant shaving off a few bytes of the code here or there.
You can try running the code in this online interpreter
https://copy.sh/brainfuck/
Remember to change memory size to 170000 first. Or use Dynamic memory but that will make it even slower. It runs about 3 minutes on my machine. Other online interpreters out there might not even run it. A better idea would be to look for faster interpreters (just remember about the memory). I used one writtern in C# that works by translating the brainfuck commands to their C equivalents.
Also, you will need a monospace font of course to see the output properly. Depending on what font you use the globe might be a bit stretched. I used Lucida console in the video.
You can download the raw source code here
http://www.zbalbous.com/bfgogquine.b
Just note that there are 255 characters per line, and at default font size and the usual screen resolution, most browsers would wrap it so you won't see it properly. Zoom out/decrease fot size to see it.
So that's it. Unfortunately this means that there won't be any esoteric challenge for the time being.
I'll come back to this when I have more time. I have a few ideas on how to make the code much smaller, but that would mean doing a lot of it back from scratch (and abandoning my 1-period-only rule). So I'll need to wait till I have more spare time.
Credits:
_A huge huge thank you to Yusuke Endoh's Qlobe for the idea and inspiration. Unfortunately I do not know Ruby, but his quine convinced me to try copy his idea in brainfuck.
http://mamememo.blogspot.ie/2010/09/qlobe.html
_Thanks to Erik Bosman's famous 410-byte quine.
Post edited June 29, 2017 by ZFR