After reading the article, I was really hoping the comments would be full of ports, glad to see this thread! Here's a version for the Inferno shell, because I couldn't resist:
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?
Python has two types of statements; "simple" statement and "compound" statements. Compound statements are those, like the if- and while-statements, which require multiple lines.
Only simple statements may be separated by a ';', not compound statements.
This is a bit different than what you wrote. For example, "x=4" is a statement, and not an expression, but "x=4;y=5;z=6" is a valid Python line because assignment is a simple statement, and multiple simple statements may be separated by a ';'.
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.
While it was far better (and thanks for the pointer to Cathode!), I figured out what the problems are. First (and probably most important), the lines being output don't touch each other, so there are horizontal gaps across the entire screen. Second, the glyphs are much thinner, reducing the feeling of "wall".
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 state machine and work with timouts just to display something.
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 to make sure the ant stayed inside the framebuffer! So the ant would happily trundle off-screen, encounter arbitrary bits that were in that memory, and would often eventually return back on the screen from a different location. Or sometimes (probably due to encountering zeros offscreen) it would run a lap around the edge of the screen and then veer back inward.
Just to be clear...it doesn't generate a labyrinth. It generates something that looks like a labyrinth, but isn't one. It's just random forward and backward slashes.
> The device you're on doesn't generate text. It looks like text, but it's really just red, green and blue dots.
Printers don't generate text. It looks like text, but it's really just ink on paper.
The point is that real labyrinths have properties these pseudo-labyrinths don't. To be specific:
> In colloquial English, labyrinth is generally synonymous with maze, but many contemporary scholars observe a distinction between the two: maze refers to a complex branching (multicursal) puzzle with choices of path and direction; while a single-path (unicursal) labyrinth has only a single, non-branching path, which leads to the center. A labyrinth in this sense has an unambiguous route to the center and back and is not designed to be difficult to navigate.
"In colloquial English, labyrinth is generally synonymous with maze" means that yes, this is a labyrinth because "labyrinth" is synonymous with "maze". "Many contemporary scholars observe a distinction between the two" means "most people don't observe any distinction between the two."
This is an interesting long-running debate in procedural generation more generally. There are a lot of approaches, hybrids between them, and orthogonal decisions, but two ends of one axis of what I'd call "procedural faithfulness" are:
1. Attempt to faithfully simulate an underlying process. An example: procedurally generate canyons by simulating water flow and erosion. Dwarf Fortress tries to take this one to its logical conclusion, doing things like simulating thousands of years of history in order to decide where to place things.
2. Produce an algorithm that mimics a desired result without necessarily using a process even close to what produced the original. Often this involves attempting to capture patterns in the original without attempting to capture why those particular patterns arose. Many grammar-based methods take this approach, such as the classic "shape grammars" used in architecture, as do data-mining approaches.
This book looks at something closer to #2 from the perspective of procedural faithfulness. But it's a variant that was particularly popular in early algorithmic art: pick an algorithm that has interesting outputs, tweak it, and see what you can do with the results. So in a sense it's closer to #1 in that its macro-properties are emergent, rather than being specifically optimized for (it's not doing things like solving for path reachability).
If generating a city, for example, you could attempt any of these approaches. You could build a little artificial agent society where you simulate agents going to work, having families, buying houses, etc., and their actions produce a city. Or, you could play with hand-coded city-generation algorithms that produce interesting patterns, and go with one. Or, you could choose specific targets or constraints (maybe culled from databases of real city geometry) and use constraint-solving or genetic algorithms or generative machine-learning algorithms to produce the desired results. Different pros and cons.
It's something I've been thinking a bit about lately, because I've been trying to understand the landscape of systems that claim to do "automated game design" [1]. Much of the work takes a simulation-based approach: tries to come up with a theory of what makes a game "balanced" or "fun", and optionally also simulates a broader theory of game design, playtesting, and revision. But another approach is to view it as crafting generative spaces of game variants, which is more of a theory of how game structure can vary than a theory of why it varies, and gives a different (not clearly better or worse) angle on the problem.
It 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?
I don't think a "corridor" ever forks, so it's not really a labyrinth where there are decisions to be made about which way to go, it's just a bunch of disjoint long, twisty hallways.
Mathematicians have given this some thought. The relevant keyword seems to be "Truchet tilings", though there's a curved variation that's more widely known. Here's a very accessible overview with some lovely generalizations of this pattern: http://mypages.iit.edu/~krawczyk/rjkisama11.pdf
Thanks, I wonder who is the idiot who downvotes an honest question.
Still, I would pay $9.99 for mobi or epub. PDF is inconvenient for the Kindle and the iPad. Converting with Calibre is a chore, and rarely yields good results.
I find GoodReader excellent for pdfs on the iPad. It's not only a great reader but also allows annotation etc plus makes getting pdfs into and out of your iPad fairly painless
I discovered this on my Commodore PET probably about 1980 and presented it at a users' group meeting (in the Los Angeles area). I have no way to prove this right now, but I swear that this is true.
The article seems to be a a lot of hyperbole without much substance.
The code itself is simple. CHR$(205.5 + RND(1)) becomes CHR$(205) or CHR$(206) depending on the random number. 205 generates a \ , and 206 generates a /.
Run it on another old-school computer, like an Apple II, and you won’t get the same transfixing result, for details that have to do with the Commodore 64’s character set, called PETSCII.
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.
I've always had a soft spot for mazes. Seeing how a recursive function could solve a maze was what got me hooked on programmng to begin with. At the time it was mind-blowing. It was the first time that software seemed like magic.
I recently read Racing the Beam (Monfort, Bogost), a survey of the defining technical details of the Atari 2600. I've read a number of gaming history books, and RtB was by far the most interesting. It might be better described as a hacker history of the platform, focusing on the limitations of the system and the hacks around them that caused Atari VCS games to have a personality distinct from its contemporaries. Also highly recommended.
Use `racket -e <expr>` tu run it directly, for Guile it should work with `guile -c <expr>` but it seems that the unicode charaters make it crash (however it works if you copy the line of code in Guile's REPL rather than on the command line with -c).
var r = 0; function go(){setTimeout('document.write(r++ % 80 ? Math.round(Math.random()) ? "\\\\" : "/" : "<br>"); go()', 100)}; go();
This was actually a lot more difficult for me to write than I thought it would be. `document.write` blocks and also a browser doesn't wrap by default, hence the r variable.
This will, of course, nuke any page you happen to run it on. :)
P.S. Why is code formatted so badly on HN these days? Until that's fixed I'll just use normal formatting.
(Save this as a .prg file and run it in your favourite C64 emulator or on the real thing itself. Please note that the first two bytes are actually required by .prg file format to indicate load address. The actual code is 11 bytes).
If you were like me back in the 80s on a PET you did that and then moved up to more complex randomness with other graphic symbols like the four corner curves or bends. I think they had that line in one issue of Creative Computing with a bunch of other character graphic effect snippets.
I remember learning this trick, not sure where I learned it from but this particular snippet had a huge impact on me. I spent hours and hours playing with variations on this.
Same fascination with this, I think, as with the simple rules of Conway's. S'pose there are other such "a-mazing" simple revelations still floating in the void?
yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash
Source and credit: http://stackoverflow.com/a/13612327