Abstract algorithmic legos

With such a title, I would usually post pictures of abstract constructions in legos, but for once I’d like to present something different.

The pictures I posted precedently are rendered in 3D using Pov-Ray, which is a free (yay !) text-based 3D software (more exactly, I’m using on my Mac a slightly different version named MegaPOV). Of course, you have to master the language used by POV-Ray to describe scenes, which can be difficult at first. However, the language is Turing-complete, which means, among other things, that you can describe everything algorithmically. For example, if you wanted 100,000 copies of the same object regularly distributed on a lattice, it takes only a couple of for… loops to do it.

Now, some people have actually written descriptions of almost all legos bricks for use in Pov-Ray: this is the LGEO library, which you can download here. With the appropriate software, for example the Lego Digital Designer and LDView, you can quickly set up a scene to be rendered in Pov-Ray. This is what I use for the usual abstract construction pictures.

Using the algorithmic possibilities offered by Pov-Ray, I wanted to check if one could program a cellular automaton with a nice graphic output. I settled for a very basic one. It consists of a 6×8 grid, where the boundaries are assumed to be periodic (so in fact this is a 6×8 torus grid). The cells of this grid contain a number which indicates the height at that position. The grid is initialized with a certain configuration (a number for each cell), and a “pointer” receives a starting position. Then, for each iteration :

  • The pointer is updated, i.e it moves on the grid according to the following rule :
  • Once in the new position, it adds one to the current cell.
  • If the height in the cell is superior to 3, the pile “collapses”, i.e the height becomes 0 and the height of neighboring cells are increased, according to the following rule :
  • The height of neighboring cells could then become superior to 3 too. In that case, we update the new configuration of the grid according to the same rule until no pile collapses anymore.

The calculation was done with a very simple C program which exported POV scenes for each iteration. Piles at each cell were rendered by stacking the corresponding height number of white 1×1 lego bricks. The program was run for 400 iterations, and images were assembled into the final movie, which you can find below or directly on youTube:

I’d like to write an automaton with a much larger grid and output, though I have to find an appropriate rule for it. This one took 2 full days to render, due to the radiosity calculations.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s