This Artificial Life exercise is more a demonstration how to program, use objects and make animation type interfaces with Visual Prolog than a serious Artificial Life model. Some links to Artificial Life pages
In chapter 2 is explained the structure of the model and in chapter 3 the general idea of the model. Chapter 4 describes the main windows and the available functions.
There are no copyright restrictions with the source code on my side expect with use of the picturesDLL.dll. PictureDLL is only allowed to be used with this project. I hope this example project gives some ideas and hints how to solve some programming problems with Visual Prolog.
If there are some limited and exact questions of this example project, send your question to firstname.lastname@example.org.
In the diagram below is an overall view of the structure of the example project. The following documentation is on a rather limited and focuses only to some main points.
The food class has two constructors. A food machine object which answers of creating the new food objects with a wanted interval. The other constructor is newFood() for new food objects.
The food object informs the creature class of a new food object.
X = math::random(right-20)+10,
Y = math::random(down-20)+10,
P = math::random(100),
This demo program uses two different foodMotors which create new foods with different shapes and intervals.
The food class inherits drawObject interface which takes care of the actual drawing.
The creatureMotor objects function is to listen to the movements of the creatures and inform the AlifeWin of the drawing need. The creatureMotor class inherits drawObject interface which takes care of the actual drawing.
CreatureMotor object has also the knowledge of the bitmaps of the different creature families. In this demo there are three different creature families with different shapes. It would be easy to add more families.
In the creatures class handles all the rules and movements relating to the creature objects. The constructor of a creature objects is
newCreature : (integer Family,
unsigned Generation) (i,i,i,i,i,i,i,i,i,i,i,i,i,i).
In this simple model the “genotype” from the mother is delivered through parameters. When the creature is “born” it goes through several mutation possibilities.
Each creature has its own timer (got from the timertool class) and it adds a timerListener to the cretureMotor object.
The creature provides class facts and class predicates to collect and fetch statistical data.
getLogReportObject: (logReport LogObj).
getSpeedFigures:() -> integer_list LIST.
getVisionFigures:() -> unsigned_list LIST.
getReproductionFigures:() -> unsigned_list LIST.
getPredatorList:() -> unsigned_list LIST.
getIntelligencePercent:() -> real.
setPlayGroundDimensions:(unsigned X,unsigned Y).
setCreatureSize : (unsigned X,unsigned Y).
The pointsWin object has three functions
The data for the family points are collected from the creatures class every 1 second using a timer. The statistics of the simulation are updated every 3 second.
Statistic class provides a frame and customControl for the statistic charts. The data is got from an external database and then transmitted to the DLL with takes care of the actual chart generating.
Pictures pack consists of a pictureControl class, a timeseriechart class which provides the predicate links to the PictureDLL. It also has lib file for that dll.
FamilyTreeWin form uses a custom control modified from the PDC’s TreeControl class.
The tree information is collected in the creatures class using the code.
% Creating family tree ********************************************************
class facts - familytree
motherChild:(string Mother,string Child).
collect_tree:(string NODE,integer N,treeControl::tree TREE) procedure (i,i,o).
collect_tree1:(string NODE,integer N,treeControl::tree TREE) nondeterm (i,i,o).
makeTree() = TREE:-
The logReport object saves all the main events of creatures’ life. It also saves the log report in a file
This class creates a report of main properties of each living and dead creature.
Tools class is a collection of tool predicates used in the project. Predicates like index, member, mean etc.
The basic idea is to see how some features of the creatures develop during time. In the pictures below is development of speed of living creatures and the population’s size. In the beginning when there are no predators the speed is not very essential. When the amount of predators increases only the fastest normal creatures survive.
Food appears in a random point of the playground every 400 ms (foodCreationInterval : integer := 400). The point value of the food is between 0 -100 points.
The food rules in this model are simple. It could be made more complex for example by adding a seasonal “flow” of food. In winter food supply is smaller than in summer.
In this example there are 3 different families or species. The start values are the same for each family.
Each creature moves by its capabilities and by the impulses it gets from the other creatures.
decideBiologicalAge() = N:-
N1 = averageLifeTime + math::sqrt(varianceLifeTime)*S ,
N = convert(integer,N1).
decideBiologicalAge() = averageLifeTime.
When a family is very dominant the predators are not “effective” because they can not mutate to cannibals in lack of food. In that case if one member of the other remaining families mutates to a predator, they have much food and can a relative short time change the situation.
A creature dies when it
Mutations of each property happen randomly when a new creature is born. The probability of a mutation in each property is 10 percent. The mutations can happen in both directions, expect that the children of predators can mutate only to cannibals. The children of cannibals are always cannibals.
The mutation increase in speed is +10 or -10 percent of the mother’s value. In Vision +20 or -10 percent and in reproduction limit +10 or -10 percent.
Which mutations survive and became dominant depends in which direction the “society” develops. In a highly competitive environment the next creature generations became faster. The predators create a long vision range. In “peaceful” society with only one family, the predator mutations have no food, so speed is not essential for surviving.
Normal creatures hunt for the food in their vision range. If a predator occurs in the vision range they try to flee.
When the points of a creature are less or equal than zero it dies.
The new creatures can mutate to a predator when it is born. It means that they do not anymore eat normal food. They eat members of other families. After catching a prey the predator spends 30 time intervals eating.
When there is no prey in the vision range the predators walk slowly to the centre of the playground.
Predators can mutate to cannibals. It means that they eat also own family members (except their mother or a mother its last child).
There are three windows.
By placing the cursor on the wanted creature and pressing the left mouse button you get the data of the creature in question.
By clicking the right button of the mouse in the Alife window you get a report in sight.
The report window has in the top left corner a button. By pressing it you can change from statistics report to a diary report. Family tree button shows the FamilyTree report.
Familytree shows the development of the creatures in a tree form. Familytree is a modification of PDC’s treeControl. It shows with colour the development of the wanted feature in each generation. The lighter the colour is the smaller the value is compared to the start value.
The Points window shows the points of each family and what is the present average of the main properties.
The Points window acts also as a link to the statistic charts. In the bottom of the window are buttons for creating the charts of the main properties. The button is enabled after 30 seconds from starting. This is because before the charts can be presented they need a minimum data.
The statTabForm form has the PDC’s tabControl. Each six different charts use a pictureControl in which the actual picture is drawn. The statistical data from the external database is transported to the PictureDLL with some picture formatting commands.
In the message window are listed the happenings in the Alife simulation. In the pointsWin is a checkbox for disabling showing messages in the Message window.