Live data from Hacker News

Show HN: Solve and generate mazes with JavaScript on HTML Canvas

github.com

21–30 of 33 posts

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#22
Bug Report: http://prntscr.com/mcyc1b

When the website loads, if I put in a large number such as 500 and hit the generate button, it does not clear the previous puzzle and overlays on top. Second click still shows it bit now its a but transparent. Third click removes it altogether. I tried to skim through the code but not sure what the cause is given that you create a new Maze every single time. It seems to be some sort of canvas rendering bug as if I clear the canvas [1] it seems to work.

1: https://stackoverflow.com/a/2142549

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#23

I explored the test site and tried different maze sizes with values in the 50s, 70s, 110s, 150 (including odd numbers). Curiously, I found the maze could be visually divided into four Cartesian-like quadrants. Consistently the middle divider had only one gap, and other major quadrants also consistently have only one gap. So, when I wondered if BFS solution might be different if I ran it multiple times, I couldn't tel…

Yeah, currently it seems large mazes are generated in 7x7 or similar blocks which are then combined to fill the area. A good example of this visually is a 29x29 or a 49x49 maze.

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#24
post #22

Bug Report: http://prntscr.com/mcyc1b When the website loads, if I put in a large number such as 500 and hit the generate button, it does not clear the previous puzzle and overlays on top. Second click still shows it bit now its a but transparent. Third click removes it altogether. I tried to skim through the code but not sure what the cause is given that you create a new Maze every single time. It seems to be some s…

Thanks a lot for the bug report! You're right - I was forgetting to clear the canvas on render. So I added ctx.clearRect(0, 0, WIDTH, HEIGHT); to the start of the render method.

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#26

I'm surprised it doesn't allow you to "draw" on it to solve the maze. That seems like an essential (and easy to add) feature.

What sort of drawing are you thinking? Dragging the mouse around on the screen or navigating with the arrows?

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#29

https://bost.ocks.org/mike/algorithms/#maze-generation has some visualizations for various different maze generation algorithms.

Great link. Here's another good one. https://www.jamisbuck.org/mazes/

I used that book to design mazes that were rendered as thick-walled SVGs so I could make them out of plywood on my laser cutter!

https://photos.app.goo.gl/UwSmp9mjWw4asBcZA

Re: Show HN: Solve and generate mazes with JavaScript on HTML Canvas

#30
post #24
post #22

Bug Report: http://prntscr.com/mcyc1b When the website loads, if I put in a large number such as 500 and hit the generate button, it does not clear the previous puzzle and overlays on top. Second click still shows it bit now its a but transparent. Third click removes it altogether. I tried to skim through the code but not sure what the cause is given that you create a new Maze every single time. It seems to be some s…

Thanks a lot for the bug report! You're right - I was forgetting to clear the canvas on render. So I added ctx.clearRect(0, 0, WIDTH, HEIGHT); to the start of the render method.

[deleted]
Post reply on HN