home subscribe to email updates subscribe to RSS updates

Experiment: Tri-Life

I had the idea for this experiment a few months ago and I’ve actually attempted it a few times - each iteration being close to what I was intending to achieve but alas, not close enough. This time I’m happy enough with the solution to release it to the world.

Michael Battle - Experiment: TriLife

I’ve decided that I’m really quite fascinated with three concepts in particular, broadly these are - 1) Automata/Intelligent Agents 2) Intransitivity (the Rock-Paper-Scissors rule set), and 3) Organising information spatially, or by proximity. You’ll see these ideas again and again throughout this site (and no doubt even more in the future!).

This latest adventure touches on all three of these concepts. Brace yourself.

So I was thinking about things that occur in 3’s… the two I settled with were Triangles (3 sides) and Colour (which can be composed of three entities, Red, Green and Blue). I briefly thought about the three dimensions of space (X, Y and Z axes), but decided to leave that until another time.

Below you’ll see a grid of triangles that are initialised to a random colour. In each iteration of the program, two phases occur: Combat and Render.

To get your head around the Combat phase, you’ll first need to know the overarching rule that Red conquers Green, Green conquers Blue and Blue conquers Red.

… Red > Green > Blue > Red …

The pseudocode for the process looks like this:

  • Figure out if I’m predominantly Red, Green or Blue by looking at my hex components.
  • Find the average colour of my three adjacent Triangles and find their predominant colour.
  • If we both have the same predominant colour, set my colour to the average between me and them.
  • If I win the fight, set my most dominant colour component to max (255) and my least dominant colour component to zero.
  • If I lose the fight, set my least dominant colour component to max and my most dominant to zero

In the Render phase… um… the Triangles get re-rendered.

So that’s pretty much it… you’ll notice a number of colourful blotches partitioned by static - this is where the fighting is currently at its most fierce!

Note - if you click the applet, each Triangle will reset to a random colour.

Hope it kinda makes sense. Let me know if you can think of other algorithms to make use of the triangle/colour partnership.

If you liked this post, you’ll probably also like:

PS - The project I’ve been sweating over launched last Friday. I’ll post about it soon.


« Alternativa3D - Flash 3D Engine
AddThis Social Bookmark Button

Related Posts:

Comments:

James said,

November 5, 2007 @ 2:36 pm

I like this idea, looks like it works well too!

As for another idea on this theme: you could do the same thing with the side of the triangle and a colour. So one side would be red, one blue one green and they’d fight on the basis of that colour strength.

You might want to have a look into self organising maps too, they have some nice colour related applications and deal with information spatially. Sort of.

Trinaryguru said,

November 12, 2007 @ 6:04 pm

Have you ever read Stephen Wolfram’s “A New Kind of Science”? It is dedicated to Cellular Automata and more. I myself have only scratched the surface so far. I have been programming Cellular Automata since I was young, long before I knew it had a name. The sample you have shown here reminds me of similar ones that I have worked on myself. Have you thought of enacting pack rules on this design? i.e. 2 of any one color trumps 1 of any other, and so on up the chain.

This may invariably lead to one dominating color but would create a new element to this experiment. Add this to what James suggested and you have strength based on overall color variance and size of grouping. Also, if you create an open environment and add attraction/repulsion rules then the groups can move to gang up on weaker elements or avoid contact with stronger ones.

Just a couple of suggestions, you may have already thought along some of these lines, but I like your experiment. Good luck and looking forward to seeing your next iteration.

Michael said,

November 13, 2007 @ 6:46 am

Hey James and Trinaryguru - great comments! Thanks very much.

I’ve heard about the Wolfram rule sets but haven’t heard about “A New Kind of Science” - I’ll look into it, thanks for that.

… and that’s a great idea regarding the pack rules. I will play with that and post the results soon.

I owe both of you a beer :)

Michael said,

November 13, 2007 @ 8:34 am

Update to my previous comment…

Wolfram’s “A New Kind of Science” is available online for free at:

Link: http://www.wolframscience.com

… I’ll have to put this in the asides section too.

Blastedt said,

November 23, 2007 @ 10:17 am

Will it eventually stop and turn one color?

Trinaryguru said,

January 19, 2008 @ 5:07 pm

It is a possibility that it would stop and turn one color in this event, then you just add other environmental aspects to the equation. Basically, what we are describing here, is an environment that would lead to a circle of life (in a sense anyways). An ant eater will trump an ant hive but a Tiger trumps and ant eater and the ants eat the carcass. There are many ways to win in a situation that has multiple variables. I guess it all just depends on the size of the system.

BTW - Have you had any progress on your system yet Michael? I would like to hear if you had any progress or if you ended up with one solid color?

Alphabet said,

August 20, 2008 @ 8:03 am

Wow, that’s really cool. I like how the areas with less combat are blurrier and the colors mix, whereas the places with a lot of combat have sharp, contrasting colors.

RSS feed for comments on this post · TrackBack URI

Leave a Comment



« Alternativa3D - Flash 3D Engine