{"id":833,"date":"2021-07-31T09:01:29","date_gmt":"2021-07-31T07:01:29","guid":{"rendered":"https:\/\/yonatankra.com\/?p=833"},"modified":"2021-08-10T16:53:37","modified_gmt":"2021-08-10T14:53:37","slug":"how-to-generate-a-maze-using-javascript-and-html5-canvas-and-a-cellular-automaton-algorithm","status":"publish","type":"post","link":"https:\/\/yonatankra.com\/how-to-generate-a-maze-using-javascript-and-html5-canvas-and-a-cellular-automaton-algorithm\/","title":{"rendered":"How to generate a maze using JavaScript and HTML5 canvas and a Cellular Automaton algorithm?"},"content":{"rendered":"\n

Generating a random map on a canvas is fun. In this article you will learn how to generate a random map or maze on an HTML5 canvas. We will use a model called Cellular Automaton.<\/p>\n\n\n\n

While there are many ways to create a maze (or a map), what I’d like to create is a map that looks more like a cave or a chasms network rather than a human-built labyrinth. The following codepen shows a live demo of the working algorithm. Just hit “Step forward” to see the algorithm iterating until you get a nice looking cave maze.<\/p>\n\n\n\n

\n See the Pen \n Cellular Automaton<\/a> by Yonatan Kra (@yonatankra<\/a>)\n on CodePen<\/a>.<\/span>\n<\/p>\n