3 ms·
I've always been a fan of generating mazes by randomly printing /, \, or a space. It ends up slanted, and there's obviously no guarantees of solvability, but it
by BoppreH 3y ago
I've always been a fan of generating mazes by randomly printing /, \, or a space. It ends up slanted, and there's obviously no guarantees of solvability, but it's surprisingly good for how simple it is.
Here's a bash version in 50 characters (https://codegolf.stackexchange.com/a/26011/7934 https://codegolf.stackexchange.com/a/26011/7934):
w=(╱ ╲);while :;do echo -n ${w[RANDOM%2]};done
and how it looks like:
https://i.stack.imgur.com/fRX05.png https://i.stack.imgur.com/fRX05.png
- heavenlyblue 3y agoSurprisingly good for what purpose?
- stevenpetryk 3y agoprobably fun
- kibwen 3y agoIt's not much fun to solve because there's no guarantee that a path exists between any given openings on the edge, so it's mostly just "pick a point on the edge at random and see how far you can get". However, it does look very pretty.
- zo1 3y agoIt's fast enough that you can just check possible outcomes for whatever criterion you want.
- nonethewiser 3y agoGenerating mazes
- deleted 3y ago[deleted]
- NelsonMinar 3y agoThat looks like a variant of Truchet Tiles: https://en.wikipedia.org/wiki/Truchet_tiles https://en.wikipedia.org/wiki/Truchet_tiles
- cbm-vic-20 3y agoThis is the modern equivalent of the classic Commodore BASIC 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
- samatman 3y agoThere's an entire book on this subject: https://10print.org https://10print.org I can't recommend it without reservation, but if you're curious what a whole book about one line of code is like, you can find out.
- rav 3y ago> there's obviously no guarantees of solvability In fact, as the size of the maze goes to infinity, the probability of solvability goes to zero. Source: https://cstheory.stackexchange.com/a/32381/20581 https://cstheory.stackexchange.com/a/32381/20581
- TMWNN 3y ago> w=(╱ ╲);while :;do echo -n ${w[RANDOM%2]};done Here is my orthogonal version: `w=(├┤┴┬─\|);while :;do echo -n ${w:$RANDOM%6:1};done` It is based on the 1-liner discussed at <https://www.youtube.com/watch?v=oPtjcSsS2MI https://www.youtube.com/watch?v=oPtjcSsS2MI>, and uses the PETSCII characters within Unicode. Screenshot: <https://imgur.com/a/YrvpAqZ https://imgur.com/a/YrvpAqZ> (from `cool-retro-term`'s Apple II profile resized to 80x25, to sort of replicate a Commodore PET's look)
- nojs 3y agoI don’t think there’s any spaces in that screenshot