Earlier quoted context omitted.
I tried to like it. I bumped up the font size to 36 points. I slowed down the loop to .01 seconds. Unfortunately, it isn't remotely the same. The C64 had magic. I miss my old C64.
Try this: http://www.secretgeometry.com/apps/cathode/ Lots of fun. Use it to make old stuff like this feel more authentic, or just run your builds in it and tell your housemates you're haxxing teh gibson. TBH though the reason it doesn't feel the same is ultimately because you're not the person you were 20-30 years ago, whoever that was. Nothing to do with the code or its execution environment.
A single line of Basic sends readers into a labyrinth
81–90 of 91 posts
Re: A single line of Basic sends readers into a labyrinth
#82Earlier quoted context omitted.
Hmm.. thats not a oneliner. Which is what makes the Basic version interesting in the first place. Also it differs in that it does not run continously. I shortened it a bit: http://js.do/code/154 Still not as elegant as the Basic version. This is one of the big downsides of how javascript is implemented in the browsers these days. There is no simple way to redraw the screen. You have to turn your whole program into a…
I won't claim this is elegant, but here's the same thing in one line: for(i=1;i " : (Math.random()>0.5) ? '\u2571' : '\u2572');
' : Math.random()>0.5?'\u2571':'\u2572'); setTimeout(draw(i+1), 100) } }(1)())
A throttled run-forever version.
edit, slightly neater:
(function draw(i){ setTimeout(function (){ document.write(i%30==0 ? '
' : Math.random()>0.5 ? '\u2571':'\u2572'); draw(i+1); }, 100) }(1))
Re: A single line of Basic sends readers into a labyrinth
#83A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
PowerShell for those on Windows: for (;;) { write-host -n (get-random ╱,╲) } Obviously this requires a font supporting those characters. MS Mincho seems to serve well: http://www.microsoft.com/typography/fonts/font.aspx?FMID=206
for (;;) { write-host -n (get-random /,\) }
It's kind of nice with _ and | too : for (;;) { write-host -n (get-random '_','|') }Re: A single line of Basic sends readers into a labyrinth
#84import java.util.Random;
public class Maze {
public static void main(String[] args) {
String[] blah = new String[] { "╱", "╲" };
Random rng = new Random();
for (;;) {
System.out.print(blah[rng.nextInt(2)]);
}
}
}Re: A single line of Basic sends readers into a labyrinth
#85A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
while true; do c=(╱ ╲);printf ${c[RANDOM%2]}; sleep .0001; done
Re: A single line of Basic sends readers into a labyrinth
#86A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
The one-line shell command python version ended up being surprisingly painful: echo "# -*- coding: utf-8 -*-\\nfrom random import choice\\nwhile(True):\\n print(choice(\"╱╲\"), end='')" | python3 or python3 -c 'exec("from random import choice\nwhile(True):\n print(choice(\"╱╲\"), end='"''"')")' (Oh, the fun of deeply nested quote escaping!) The exec / echo thing being required since we need multiple lines, because wh…
python3 -c "`echo -e 'import time\nwhile True:\n print(u"\u2571\u2572"[int(time.time() * 100)%2],end="")\n time.sleep(0.001)'`"
The neat thing about it is that the randomness comes from the inexactness of time.sleepRe: A single line of Basic sends readers into a labyrinth
#87A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
The one-line shell command python version ended up being surprisingly painful: echo "# -*- coding: utf-8 -*-\\nfrom random import choice\\nwhile(True):\\n print(choice(\"╱╲\"), end='')" | python3 or python3 -c 'exec("from random import choice\nwhile(True):\n print(choice(\"╱╲\"), end='"''"')")' (Oh, the fun of deeply nested quote escaping!) The exec / echo thing being required since we need multiple lines, because wh…
python -c "while 1:import sys,random;sys.stdout.write(random.choice('\/'))"
and it's shorter too !Re: A single line of Basic sends readers into a labyrinth
#88It may be somewhat interesting to analyze the properties of randomly-generated labyrinths of this type. For instance, some spaces are clearly enclosed. i.e., there is a finite border outside which you cannot escape. Some paths seem to run on for a very long time. Are all paths enclosed? If so, given a random point on a randomly generated maze, what is the average area of an enclosure?
Re: A single line of Basic sends readers into a labyrinth
#89Another fun example of a computer generating mezmerizingly complex art from simple code is that as a kid, I wrote a Langton's Ant implementation in QBASIC on a DOS machine (don't remember the version). IIRC this was using Graphics Mode 1 (320 x 200 pixel framebuffer), and I used PSET and PRESET to draw white and black pixels. This so far sounds ordinary but: The cool thing was that I forgot to write the bounds check…
I had the same bug (no pun intended), but in JavaScript. It does produce some interesting effects after making a few laps. http://chengsun.github.com/walk.html I still am a "kid", and it amuses me that I'm making the same stuff on modern platforms that have already been done on DOS machines by kids like me.
Re: A single line of Basic sends readers into a labyrinth
#90A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
Interactive JavaScript version: http://js.do/samples/labyrinth
JS: for(i=0;iCSS: body {line-height: 1}