41
22
I know there is an (old) thread similar to this (here), but I'd like to reboot it with some modifications.
The goal: generate a random-looking maze using an algorithm of your choice, then output the maze graphically (printing counts).
- The width and height are determined by you.
- There should be at least one path from at least one entrance to at least one exit.
- The format of the maze (how you display it, mark entrance(s) or exit(s)) is up to you as well.
- The prettier, the better.
- Trivial mazes (e.g. blank mazes, lattice mazes, mazes of size 1x1) are discouraged.
- Cycles in the maze are allowed and, are encouraged, if the result is reasonable.
- Language abuse encouraged.
- The maze should look reasonably random (but a completely deterministic (e.g. chaotic) algorithm that generates this is fine too).
Edit: the main focus here is on making the smallest possible implementation. However, I want to allow some leeway within that constraint to encourage shininess. I have deliberately left exactly what "features" the maze has open-ended, but as a rough guideline you should try to pack the most amount of bang into the least lexical buck.
What does "random-looking" mean? Can I get away without a single call to the
rand()
-equivalent of my function as long as the output looks like a mess? – Martin Ender – 2014-04-17T09:06:42.4004Also "The prettier, the better" seems hardly tangible (or simply irrelevant) to a code-golf challenge. Maybe a popularity contest would be the better choices if you're interested in pretty results. – Martin Ender – 2014-04-17T09:59:20.430
5So is it really code-golf or is it rather popularity-contest? – l0b0 – 2014-04-17T11:37:10.623
2As another suggestion, if you do want to incentivise both short codes and neat mazes, you could make it a code-challenge and declare that the winner will be selected by some score that is a mixture of code length and upvotes - although it'll be up to you to determine each answers total score, because including the current number of upvotes in the post is a bit useless. – Martin Ender – 2014-04-17T13:11:50.423
3I think each answer should explain what constitute entrances and exits in each maze (as well as, what's a wall and what's a passage), so that we can evaluate the 2nd bullet. – LarsH – 2014-04-17T16:41:09.633
I want this to be a popularity-contest. We'll see more inventive mazes that way. – Kevin – 2014-04-18T19:42:00.587
1You should also remove the [code-golf] tag then. I'm not sure it's going to go over so well though, since there are multiple golfed entries already. – Geobits – 2014-04-18T19:57:52.563
2@Geobits I wouldn't mind too much, but hence my suggestion to actually make it a code-challenge with combined scoring from code length and votes. That would exactly encourage what the OP wants: short code for interesting mazes. – Martin Ender – 2014-04-18T20:34:52.653
I wouldn't mind a change of scoring system either, this is supposed to be a bit of fun. However it can't stay as it is now with both code-golf and popularity-contest, those are incompatible and close votes will start because of the ambiguous winning criterion. If you want to consider both, a better way is a formula combining votes and bytes, like this question: http://codegolf.stackexchange.com/questions/23581/eiffel-tower-in-3d
– Level River St – 2014-04-18T21:57:00.817I'm not going to make a troll answer here, but I don't think that anyone is going to beat this (assuming it is a code golf).
– Isiah Meadows – 2014-04-20T02:40:03.037Matter of fact, if it uses that algorithm, it should be immediately downvoted (it does not guarantee a start and end point). – Isiah Meadows – 2014-04-20T02:47:10.110
Having taken this far too seriously, I've now got 60 lines (2000 characters) of original Spectrum BASIC using a combination of Recursive backtracker and Hunter-Killer algorithms (http://www.astrolog.org/labyrnth/algrithm.htm), so no hope of winning a golf contest, but the mazes sure are purty.
– Brian – 2014-04-20T16:25:40.400@impinball it DOES guarantee start/endpoint. If you consider the blank area to be the path, any point on the edge of the maze leads trivially without branching to another point on the edge (theoretically all paths on the edge of the maze could be only 2 squares long but the odds of this happening are minuscule, you normally get some nice long random walks.) On the other hand if you consider the printed area as path, fairly large mazes are formed (corollary of the fact that they must be bounded by unprinted areas) and you get interesting mazes, as seen in my answer. The problem is picking one. – Level River St – 2014-04-20T21:31:38.410