Huegene

I first heard about Huegene after watching the following video from Dave Ackley.

Similarities to Wa-Tor

Huegene is similar to Wa-Tor with the following differences;

1. Plants and herbivores rather than fish and sharks.

2. Plants cannot move like fish can. They spread through self propagation.

3. Herbivores have a probability chance of eating plants based on how close in color the herbivores and plants are.

Color Genes

Both the plants and herbivores have genes that determine their color.

When a new plant or herbivore is created it has a slightly mutated color from the parent. This results in plants growing in clumps of similar colors.

Plant Consumption Probability

This is the main difference between Huegene and Wa-Tor. In Wa-Tor the sharks happily gobble up any fish they land on. In Huegene the herbivores have a probability of eating a plant based on how close in color they are to the plant. So a blue herbivore will have a greater chance of eating a light blue plant than a yellow plant.

Herbivores eat the plants around them with the most similar color, which leads to the less similar plants in the area being able to thrive which then have more resistance to the herbivores in the area. The herbivores also mutate and can adapt to eating the new plant colors. This feedback cycle continues as the plants and herbivores adapt to the changes in each other.

Gene Color Methods

For the gene colors I use the following 3 options;

1. Hue. Hue is a floating point value between 0 and 1. For display the HSL(hue,1.0,0.5) value is converted to RGB.

2. RGB. Each plant or herbivore has 3 color genes for red, green and blue.

3. Hue and Saturation. Hue is between 0 and 1. Saturation is between 0.5 and 1. For display the HSL(hue,saturation,1) value is converted to RGB.

The following three sections explain how these different gene methods are used to determine a probability of a herbivore eating a plant next to it.

Hue Genes

Hue is a floating point value between 0 and 1. It is converted to RGB values for display.

The following code is used to determine if a herbivore eats a plant near it.


//difference between hue values
difference=max(herbivorehue,planthue)-min(herbivorehue,planthue);
//wraparound difference - make sure difference is between 0 and 0.5
if difference>0.5 then difference:=1-difference;
//scale difference to between 0 and 1
difference=difference*2;
//test probability
if random*probabilityfactor<(1.0-difference) then EatPlant

The difference takes into account the fact that the Hue values wrap around from 1 back to 0 on the hue color wheel. For example, if you have a plant hue at 0.1 and a herbivore hue at 0.9 you want their difference to be calculated as 0.2 and not 0.8.

I also added a “probability factor” in. If this is greater than 1 it lessens the chance of the herbivore eating the plant. If you get a simulation that the herbivores are too plentiful increasing this factor will help keep them under control.

RGB Genes

Each plant and herbivore now has 3 red green and blue values that are used for display and the probability of the plants being eaten by herbivores.


//difference between RGB values
difference=sqrt(sqr(herbivorer-plantr)+sqr(herbivoreg-plantg)+sqr(herbivoreb-plantb))/255;
//test probability
if random*probabilityfactor<(1.0-difference) then EatPlant

Hue and Saturation

Now takes into account hue and saturation values. Hue is between 0 and 1. Saturation is between 0.5 and 1.


//difference between hue values
difference=max(herbivorehue,planthue)-min(herbivorehue,planthue);
//wraparound difference - make sure difference is between 0 and 0.5
if difference>0.5 then difference:=1-difference;
//saturation contributes 50% of difference value
difference=difference+(max(herbivoresat,aPlant.sat)-min(herbivoresat,aPlant.sat));
//test probability
if random*probabilityfactor<(1.0-difference) then EatPlant

Other Examples

Plants actively look for empty neighbor locations to spread into. Herbivores move at random rather than actively looking for plant neighbors.

Plants actively looking for empty neighbors. Herbivores hunting for available plant neighbors.

Plants spread randomly. Herbivores hunt for available plant neighbors.

Sample Movie

Extension Into Three Dimensions

This next movie extends 2D into 3D. Same logic and parameters as the 2D movie, just adding the third Z dimension into the calculations.

The next movie averages the colors of the cells for display. The simulation genes themselves are not averaged/blurred, just the display colors. This cuts down the color noise and allows the more general waves of plant types to be seen. Or maybe it doesn’t? Anyway, it is another option to experiment with.

Availability

Huegene is now included in Visions of Chaos.

Jason.

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