Another 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…
A single line of Basic sends readers into a labyrinth
51–60 of 91 posts
Re: A single line of Basic sends readers into a labyrinth
#52If you have a machine with a UTF-8 terminal and a recent-ish Perl (tested on Perl 5.10 + Mac OS X 10.6), you can play along at home by running: perl -e '$ |= 1; binmode(STDOUT, ":utf8"); while (1) { print chr(9585.5 + rand()); select(undef, undef, undef, 0.01); }'
Re: A single line of Basic sends readers into a labyrinth
#53Earlier quoted context omitted.
Ruby: echo 'loop do print ["\u2571","\u2572"].sample end'|ruby
This makes it slower, so it's more pleasant to watch: echo 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'|ruby
The C64 had magic. I miss my old C64.
Re: A single line of Basic sends readers into a labyrinth
#54If you have a machine with a UTF-8 terminal and a recent-ish Perl (tested on Perl 5.10 + Mac OS X 10.6), you can play along at home by running: perl -e '$ |= 1; binmode(STDOUT, ":utf8"); while (1) { print chr(9585.5 + rand()); select(undef, undef, undef, 0.01); }'
Re: A single line of Basic sends readers into a labyrinth
#55If you have a machine with a UTF-8 terminal and a recent-ish Perl (tested on Perl 5.10 + Mac OS X 10.6), you can play along at home by running: perl -e '$ |= 1; binmode(STDOUT, ":utf8"); while (1) { print chr(9585.5 + rand()); select(undef, undef, undef, 0.01); }'
While interesting, it isn't the same. I'm not sure what, exactly, the difference is, but I don't get the feeling of "labyrinth". Instead, I get the feeling of a bunch of similar glyphs.
Re: A single line of Basic sends readers into a labyrinth
#56Re: A single line of Basic sends readers into a labyrinth
#57Python version: python -c 'import random; print "".join(random.choice(r"/\\") for i in range(80*24))'
python -c 'import random; print "".join(random.choice([u"\u2571",u"\u2572"]) for i in range(80*24))'Re: A single line of Basic sends readers into a labyrinth
#58It 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
#59A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
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 while ';' is the statement separator python barfs on "import foo; while (True): pass". Bug or spec?
Re: A single line of Basic sends readers into a labyrinth
#60A version that works in bash: yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash Source and credit: http://stackoverflow.com/a/13612327
wm/sh -c 'load std mpexpr;while{}{unicode -t ${expr 2571 1 rand +}}'