Posts

Showing posts with the label visualization

Building an 8-bit addition calculator with circuits

Image
Pt En I have a childhood friend that had very interesting toys... He used to play around with circuits, multimeters, LED lights, small batteries, etc. I loved going to his house and watch him play with all that. That is probably why I find circuits (in their basic form) very interesting: the current flowing and the logic gates operating on the circuits and whatnot. Because of that, in this post I will show you how to build an 8-bit addition calculator just with circuits! For that I will be using logic.ly , a circuits simulator that I can run in my browser. The best way to go about this is by starting with small components and then using a nice feature of logic.ly, which enables one to create "integrated circuits": it takes one circuit we created and transforms it into a single piece. Of course that before anything else one must know how to add two numbers in binary. It is essentially the same as in with decimal numbers, except that $1 + 1 = 10$ now. To c...

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...