4 ms·
The link you provided suggests it is a 'simple maze'? What is a true maze by your definition?
by acjacobson 12y ago
The link you provided suggests it is a 'simple maze'? What is a true maze by your definition?
- mxfh 12y agoOne that has at least an entry and a connected exit or some defined goal somewhere in the maze with a connection to the exit. For proper maze generation see: http://en.wikipedia.org/wiki/Maze_generation_algorithm http://en.wikipedia.org/wiki/Maze_generation_algorithm Here's a simple JS snippet that overwrites any loaded page in the browser when pasted into the console. Or live here: http://jsfiddle.net/15fmx4L7/ http://jsfiddle.net/15fmx4L7/ var d = document, tiles = ["\u2571","\u2572"], i = 0, s = 12, b, s, l; d.open(); d.write("<html><body>"); b = d.body; b.style.cssText = "font-size:" + s + "px;" b.style.cssText += "word-wrap:break-word;padding:0;margin:0;line-height:100%"; l = Math.floor(b.clientHeight/s) * Math.floor(b.clientWidth/s); while (i < l) { d.write(tiles[Math.round(Math.random())]); i++; } d.write("</body></html>") d.close(); It's dead simple and relies a lot on known output formatting, which requires some CSS fluff. The core function though is a simple stream of random code points from a set of two, really nothing spectacular to see here: while (1) {document.write(["\","/"][Math.round(Math.random())]);} This does not generate a maze, it's a pure tiling side effect, which might generate by chance a tunnel through the pattern. If you look closely you'll find no T-type intersections or any other kind of path bifurcation.
- RodgerTheGreat 12y agoIn K you could do: {x}{`0:"/\\"1?2;x}/1 {x}{...;x}/1 is essentially while(true) {}. `0: writes values to standard output. "/\\"1?2 indexes into a two element array given the result of selecting one random result from the numbers up to but excluding 2.
- DanBC 12y agoHere is thirteen bytes of your program: var d = docum