Artificial Life Simulation

I have many software projects that I have been working on. One of my favorites is an Artificial Life Simulation. I will be using the blog portion of mikestratton.net to keep a running record of my work. The Artificial Life Simulation is being developed in Java.

Artificial Life Simulation Overview

Create a simulation that emulates life and evolution.
The simulation is governed by the same rules that govern our world. Graphic
objects in simulation represent life forms and environmental objects. Life
forms have attributes that evolve dependent on the success of each attribute
(i.e. unsuccessful attributes drop off; successful attributes are accented or
further developed). The purpose of the life forms is survival.

Psuedo Code (Simple Version)

// artificial life psuedo code simple

public class alpcs
{
public static void main( String[] args )
{
int p; // plant
int h; // herbivore
int c; // carnivore

// reproduce every 1 minute
// plant to animal ratio
method reproduce
{
new
p = 20;
h = 6;
c = 4;
// adjust reproduction dependent on p:h:c ratio
// p:h:c ratio = 10:3:2
if (p/(h+c) > 2)
p = 20;
h = 12;
c = 8;
else if
(p/(h+c) < 2)
p = 20;
h = 6;
c = 4;
else if
(p/(h+c) == 2)
p = 10;
h = 3;
c = 2;
return p,h,c;
// reproduce every 1 minute
// herbivore to carnivore ratio
// h:c ratio = 3:2
if (h/c > 1.5)
p = 10;
h = 3;
c = 4;
else if
(h/c < 1.5)
p = 10;
h = 6;
c = 2;
else if
(h/c == 1.5)
p = 10;
h = 3;
c = 2;
return p,h,c;
} // end method reproduce

method nest // reproduction takes place in nest
{
hnest = orange, 12×12, x/y coordinate; // size, location, and color of nest
cnest = orange 12×12 x/y coordinate; // size, location, and color of nest
} // end method nest

method pGrowth
{
p = plantFood; // number of returned plants transform from plantGrowth to plants
} // end method pGrowth

method move
{
string plant = 4×4 green; // 4×4 green square
string herbivore = 4×4 blue; // 4×4 blue square
string carnivore = 4×4 red; // 4×4 red square
p = number of plant;
plant is stationary
h = number of herbivore
herbivore moves randomly at rate of 4 units/second
c = number of carnivore
carnivore moves randomly at rate of 5 units/second

} // end method move

method sight
{
if (carnivore x coordinate/y coordinate + 4 = herbivore)
carnivore move towards herbivore
else if (herbivore x coordinate/y coordinate + 3 = carnivore)
herbivore moves away from carnivore
} // end method sight

method die
{
plant, herbivore, carnivore = 4×4 brown, stationary // 4×4 brown stationary square
4×4 brown = pFood; // plant, herb, or carn dies, plants can grow
} // end method die

method eat
{
if (carnivore x coordinate/y coordinate + 1 = herbivore)
herbivore = method die;
else if
(herbivore x coordinate/y coordinate + 1 = plant)
plant = method die;
} // end method eat

method health
{
if (herbivore eat > 1 minute or carnivore time > 3 minutes)
herbivore = method die
if (carnivore eat > 1 minute or carnivore time > 3 minutes)
carnivore = method die
if (plant time > 3 minutes)
plant = method die
if (pFood > 3 minutes)
remove pFood
} // end method health

} // end method main
} // end class alpcs

0
  Related Posts