Posts

Showing posts from June, 2018

Pocket maths: the birthday bet

Image
Pt En This post has been translated here . Este artigo está traduzido aqui . &nbsp&nbsp- RGS join the mathspp mailing list

Random maze generation

Image
Pt En In this post I just want to share a simple algorithm that I used to create random mazes. The idea came from an e-mail I got, about a past competition, where one of the contestants did this exact thing: a program to generate random mazes. I saw the animation of the program working here and I deduced how to do it. All the code can be found on GitHub , as well as an executable of the program, the animations from the beginning and end of this post, an image of a bigger maze, and this other animation: where you can see a different style of maze; a less straight one. The maze starts in the top left red corner and ends wherever the other red square is, which need not be on the bottom right corner. The algorithm is simple: travel randomly inside the black area without ever hitting a white path; whenever no random move can be made, start going back until you find a place where the path can branch out again. While we are creating white paths, keep updating the fin