School algorithmic project : Cellular Automata

Project 22

Caracteristics

Description

My first project in my ENSEIRB-MATMECA curriculum is an algorithmic project done in C. I did my project in a groupe of two, my work partner was Dimitri Walther . The project lasted for 3 months and in my opinion, I found the topic really interesting. The subject was about cellular automata, and the behavior of certain rules was inspired by the game Noita. With Dimitri, we worked on the same parts of the code.

Initially, we planned to create the Game of Life by reprsenting live cells with multiple colors. The core of the game was easy to reproduce. The multicolor issue was solved fairly easily. The colors displayed on the screen were reprensented by numbers ranging from 0 to 16777215, so we used the additional numbers to represent diffent types of cells, different materials. So the number for dead cells was max+1 and for living cells was max+2. Then during the image creation phase, our system converted these unviewable colors (numbers) into random colors we defined to correspond to that material. Despite solving the previous issue, we encountered a new one, the color of cells changed event if they didn't move or when they move and we don't want to. Meaning that a material represented by multiple colors, was asigned randomly each frame to our cells. To resolve the issue wa created a special type, a special number, named "last color", a convention taht tells the updating system that the cell's color should remain the same for the next image. This system was also working for moving cells.

Our second objective was to recreate the behaviour of sand, like in Noita. We wanted to make a more generalist system, so we made a system with particles (like sand grains) that move. The particles follow their modification rules (e.g., move diagonaly). Their rule give them their next position and material. Here how our system is working. Our system first went through all the cells to fill a queue of rules to be applied. Then, the system look for each cell which cells wanted to move on it. Base on this fact, we constructed a graph and performed a cycle detection. In the case where multiple cells wanted to move to the same cell, we chose one at random, and for cells in a cycle, we performed a permuation of one step.

To test compression, we imagined two cases : a sand block and two moving bars of cells, one moving to the left and one moving to the right. The purpose of the sand block was to check if the sand was falling in one block. Or if upper cells of sand wasn't eable to fall because they where sans cell under it at this frame. While the goal of the second test with both bars was to verify taht they would crash and stop when they encountered and that cells was not disapearing. In the other hand, to test cycles, we created an area with a full column of sand. As the area is toric, then the column was to supposed to fall indefinitely. The visuals below illustrate this.

Finally, our last goal was to develop random events. With this in mind, we created heavy sand cells and dynamite cells. The behavior of dens sand was to exchange positions with thin sand at a random time. Similarly, the dynamite was supposed to explode at a random moment.

Visuals - (Click on one pick to enlarge it)

Physics Simulator, a pile of fine and heavy sand, and stone. Physics Simulator, heavy sand starts to fall under the fine sand. Physics Simulator, all heavy sand is now under the fine sand. Physics Simulator, layer of sand in the air. Physics Simulator, layer of sand collides with stone. Physics Simulator, layer of sand falls to infinity. Physics Simulator, dynamites before explosion. Physics Simulator, state of the terrain after explosion. Physics Simulator, layer of sand falling to infinity, test for full cell columns. Physics Simulator, layer of sand falling to infinity, sand is actually falling. Collision test, the red and orange line moves to the right, the white and blue line moves to the right Collision test, collisions are well respected. Game of life, initial configuration. Game of life, advanced simulation. Game of life, almost nothing happens anymore. Project organization.

Hey test test