7 ms·
For me it's a BASIC one-liner which generates mazes 10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10 I found this specific one via slashdot[1], but something simi
by vatys 7y ago
For me it's a BASIC one-liner which generates mazes
10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10
I found this specific one via slashdot[1], but something similar, which I've never managed to find/replicate, was used to generate mazes on the Atari 800 XL at my school when I was a kid.
[1] https://developers.slashdot.org/story/12/12/01/1847244/how-does-a-single-line-of-basic-make-an-intricate-maze https://developers.slashdot.org/story/12/12/01/1847244/how-d...
- th0ma5 7y agoIn action: https://youtube.com/watch?v=m9joBLOZVEo https://youtube.com/watch?v=m9joBLOZVEo
- flohofwoe 7y ago...or in a live emulator :) https://floooh.github.io/tiny8bit/c64.html?input=${wait:200}10%20PRINT%20CHR%24%20(205.5%20%2B%20RND%20(1))%3B%20%3A%20GOTO%2010%0ARUN%0A https://floooh.github.io/tiny8bit/c64.html?input=${wait:200}...
- Waterluvian 7y agoOh wow this is a cool loop closure. I wrote a CHIP 8 emulator to learn stuff and my main test rom was this program. I walked through the bytecode very slowly as I learned and debugged and repeatedly wondered how the heck the program was so tiny.
- jointpdf 7y agoThere’s actually an entire book on this at: https://10print.org/ https://10print.org/
- symplee 7y agoWhat is the probability that it prints a completable[0] maze? Expressed in terms of line width (w) and number of lines (n). [0] Where there's a valid path from the first line to the last.
- scrollaway 7y ago1/2^n, I believe (where n is the number of lines after the first one, otherwise 1/2^n+1). So halved every time: 100% with 1 line, 50% with 2 lines, 25% with 3 lines, and so on. Width is irrelevant (you can do this in your head comparing w=1 n=2 to w=2 n=2 for example). Edited for clarity and accuracy.
- Const-me 7y agoOne line, not completable: /\/\/\/\ Also, I don't believe it doesn't depend on width. I think with constant height, the probability of completable one should increase with width, and become almost 1 for very large widths.
- scrollaway 7y agoHm, good points, looks like I need more sleep. Looking at the video again, a path is valid if two slashes follow each other, with the same pattern shifted by 1 the line below. But I wasn't treating /\ as an invalid on the first line. Eg thinking of: /\/\/\/\ \\////// /\\\\\\\ … and so on (Using the /\ pattern, paths can go back up and come back down, so this requires a lot more thought than I instinctively put into it)
- zmix 7y agoWow! This is really cool. I just entered it quickly in a C64 emulator and it ran, creating a maze. Not sure, whether it would be a solvable one, but it is interesting to note, that the paths are really connected!
- tasuki 7y ago> the paths are really connected! What do you mean by that?
- zmix 7y agoThe paths make sense. I.e. you got uninterrupted lines, surrounded by walls, so it is a real maze and not just a lookalike or partial maze. Oh, and it's a-maze-ing! :-)
- tasuki 7y agoI'm still not sure what you mean. It just prints / and \ randomly. What is a maze lookalike and partial maze? Would you mind sharing any examples?
- codecritic 7y agoNo, it does not generate a maze. It generates a random sequence of \s and /s, that can trigger a maze being generated in a typical user's mind. This is the art of illusion.
- henkslaaf 7y agoWhat is a maze? One could argue that if the user perceives a maze, then it produces a maze.
- ljm 7y agoNever expected to find myself on the path to enlightenment after reading a line of BASIC.
- lmilcin 7y agoMaze has a starting point and a goal. The goal must be reachable from the start.
- Intermernet 7y agoOnly if you want to give the occupant of the maze a chance to escape :-)
- wincy 7y agoSo this would be more of a labyrinth than a maze?
- cyphar 7y agoNo, a labarynth is a single twisting route without branches. A maze has branches and thus can have dead-ends. Both must have an entry and exit point (technically mazes may have more than one exit and entry, but most don't).
- jedberg 7y ago> a labarynth is a single twisting route without branches. A maze has branches and thus can have dead-ends. I was today years old when I learned this.
- ssdsa 7y agoThis, as a WebGL shader in shadertoy: https://www.shadertoy.com/view/ld23DW https://www.shadertoy.com/view/ld23DW
- _jon_ 7y agoThe mysterious maze algorithm of Atari game Entombed: https://www.bbc.com/future/article/20190919-the-maze-puzzle-hidden-within-an-early-video-game https://www.bbc.com/future/article/20190919-the-maze-puzzle-...
- ElCapitanMarkla 7y agoThat was great, thanks
- Shinchy 7y agoI love it!
- tyingq 7y agoPerl version if you don't have a BASIC interpreter handy: perl -C -e 'print chr(9585.5+rand) while 1'
- morazow 7y agoohh wow, I remember being fascinated with Pascal program that makes snow fall. Basically, it was white dots on a blue background in an infinite loop. :)
- cr0sh 7y agoSomewhere I have a copy of a BASIC program I typed into my TRS-80 Color Computer as a kid, from an issue of K-Power magazine. I don't recall if it was one of the full issues, or one of the "insert issues" found within Family Computing of the era. It was a special kind of "snow fall" generator; IIRC, there were only a couple of versions, one for the Apple IIe and the other for the PCjr - I likely used the PCjr version for the conversion since the BASIC language was nearly identical between the PCjr and my CoCo 2. What was special was that it managed to seemingly move hundreds of pixels relatively rapidly on the screen; now, this might not seem like such a feat, but it really was considering we're talking about a computer system running an interpreted BASIC program, with a max speed below 1 MHz in standard mode (0.89 MHz - there was a so-called "speedup poke" that "doubled" the speed - POKE 65495,0 if anyone cares). I don't recall what trick it used - or if it really used anything special at all - but I do remember being impressed by that bit of code.
- lasagna_coder 7y agowhile [ 1 ]; do for i in `seq 1 80`; do printf "\xE2\x95\xB$(( ( RANDOM % 2 ) + 1 ))"; done; printf "\n"; done
- gpsx 7y agoThat is very cool, but does it produce no branches?
- kwoff 7y agoIf we define "elegant" as getting a lot done with a little, another BASIC (kinda..) one: https://linusakesson.net/scene/a-mind-is-born/ https://linusakesson.net/scene/a-mind-is-born/ (The last part of the song is so great, too.)