Posted June 29, 2017
high rated
TLDR:
New and improved GOG.com brainfuck globe quine
https://www.youtube.com/watch?v=ob2zLvE23Lo
Code:
http://www.zbalbous.com/bfgogquine.html
http://www.zbalbous.com/bfgogquine.b
A quine is a computer program that prints out itself. This one is written in brainfuck and it does print itself, except that the globe part of it gets rotated by 1/50th of a cycle. After 50 iterations you get the original code back. In essence, every frame of the video is valid brainfuck code that outputs the next frame.
The long version:
Almost a year ago I created a brainfuck quine that besides printing itself also formed a globe with GOG.com logo that would get rotated with each iteration.
Unfortunately that final product was way too long. A year later, I've finally finished my new and improved version. The new code is much smaller than the old one. If we include the globe, it's about 64% of the old one's size. It's also "better" in the sense that less stuff is hard coded, though as a result it needs a bit more tape memory.
This is much closer to what I envisioned when I started this project. The globe is actually in a prominent place and occupies a large part of the code, rather than being a small circle somewhere at the bottom.
You can compare the results for yourself.
Old version: https://www.youtube.com/watch?v=ws-bRLdMJrs
New version: https://www.youtube.com/watch?v=ob2zLvE23Lo
I realize that after all this work it's still just a globe, just like the old version, but reducing the size of the code did take some work. I'm happy it's done.
Oh, and the new version also contains only one single period "." neatly hidden in my email.
For the time being this is going to be the final version. I don't have any ideas on how to meaningfully improve it at the moment.
If you want to run the code, note that:
_It uses 8-bit size cells, which is the usual implementation.
_You need a memomry size of 175,000 (!). 174,116 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.
You can try running the code in this online interpreter
https://copy.sh/brainfuck/
Remember to change memory size to 175000 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.
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.
EDIT (09/06/2018):
Full code with comments is now available
https://www.gog.com/forum/general/my_new_and_improved_gogcom_brainfck_quine_v2/post15
https://www.dropbox.com/s/ye3ufzb286yvyt6/GOG%20globe%20quine%20with%20notes.zip?dl=0
New and improved GOG.com brainfuck globe quine
https://www.youtube.com/watch?v=ob2zLvE23Lo
Code:
http://www.zbalbous.com/bfgogquine.html
http://www.zbalbous.com/bfgogquine.b
A quine is a computer program that prints out itself. This one is written in brainfuck and it does print itself, except that the globe part of it gets rotated by 1/50th of a cycle. After 50 iterations you get the original code back. In essence, every frame of the video is valid brainfuck code that outputs the next frame.
The long version:
Almost a year ago I created a brainfuck quine that besides printing itself also formed a globe with GOG.com logo that would get rotated with each iteration.
Unfortunately that final product was way too long. A year later, I've finally finished my new and improved version. The new code is much smaller than the old one. If we include the globe, it's about 64% of the old one's size. It's also "better" in the sense that less stuff is hard coded, though as a result it needs a bit more tape memory.
This is much closer to what I envisioned when I started this project. The globe is actually in a prominent place and occupies a large part of the code, rather than being a small circle somewhere at the bottom.
You can compare the results for yourself.
Old version: https://www.youtube.com/watch?v=ws-bRLdMJrs
New version: https://www.youtube.com/watch?v=ob2zLvE23Lo
I realize that after all this work it's still just a globe, just like the old version, but reducing the size of the code did take some work. I'm happy it's done.
Oh, and the new version also contains only one single period "." neatly hidden in my email.
For the time being this is going to be the final version. I don't have any ideas on how to meaningfully improve it at the moment.
If you want to run the code, note that:
_It uses 8-bit size cells, which is the usual implementation.
_You need a memomry size of 175,000 (!). 174,116 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.
You can try running the code in this online interpreter
https://copy.sh/brainfuck/
Remember to change memory size to 175000 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.
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.
EDIT (09/06/2018):
Full code with comments is now available
https://www.gog.com/forum/general/my_new_and_improved_gogcom_brainfck_quine_v2/post15
https://www.dropbox.com/s/ye3ufzb286yvyt6/GOG%20globe%20quine%20with%20notes.zip?dl=0
Post edited June 09, 2018 by ZFR