Evolife

Jean-Louis Dessalles

1. Overall description
2. How to execute Evolife (+ download)
3. Evolife source files
4. Evolife classes and functions
5. How Evolife works
6. Create your own Evolife scenario
7. Use Evolife’s components separately (graphics, ecology, genetic algorithm)

↪ Program documentation

## 7. Create you own Evolife scenario

Evolife allows you to study an evolving population, either to implement a genetic algorithm or to perform some ecological study. If you do not need all of this, consider section 8 about using only some of Evolife’s components.

Evolife scenarios vary:

1. by parameters and values defined in the configuration file (xxx.evo) that you load with starter.
2. by different default functions implemented in Default_Scenario.py (in Scenarii) that you can redefine.

There are several possibilities to create your own scenario by rewriting functions from Default_Scenario.py:

- Customize an existing scenario by copying and modifying an existing scenario Scenarii/S_xxx.py.
- Alternatively, customize Scenarii/CustomScenario.py. The program imports everything it needs from Evolife, and reads the configuration file MyCustomScenario.evo.
  Choose this option only if you need to re-implement one of the classes: Individual, Group, Population, Observer.

### Customizing a scenario

You may look in Scenarii for the scenario that is closest to what you wish to do. Let’s mention:

- S_SumBits.py: a simple genetic algorithm
- S_Labyrinth.py: a genetic algorithm with phenotype
- S_Favourable.py: a simple ecological simulation
- S_Void.py: a void scenario that you can customize

You may cut-and-paste and rewrite all functions inherited from Default_Scenario (defined in Default_Scenario.py). These include:

1. – initialization(self): allows to define local variables
2. – genemap(self): initialises the genes on the gene map (see Genetic_map.py)
3. – phenemap(self): defines a list of phenotypic character names (see Phenotype.py)
4. + season(self, year): makes periodic actions like resetting parameters
5. + behaviour(self, BestIndiv, AvgIndiv): defines a behaviour to be displayed
6. + life_game(self, members): defines a round of interactions – calls the five following functions
7. – start_game(self, members): group-level initialization before starting interactions
8. – prepare(self, indiv): individual initialization before starting interactions
9. – interaction(self, Indiv, Partner): defines a single interaction
10. – partner(self, Indiv, members): select a partner among members that will interact with Indiv
11. – end_game(self, members): an occasion for a closing round after all interactions
12. – evaluation(self, Indiv): defines how the score of an individual is computed
13. – lives(self, members): converts scores into life points
14. + couples(self, members): returns a list of couples for procreation (individuals may appear in several couples!). Calls the following function):
15. – parenthood(self, RankedCandidates, Def_Nb_Children): Determines the number of children depending on rank
16. – parents(self, candidates): selects two parents from a list of candidates (candidate = (indiv, NbOfPotentialChildren))
17. + new_agent(self, child, parents): initializes newborns
18. + remove_agent(self, agent): action to be performed when an agent dies
19. + update_positions(self, members, groupID): assigns a position to agents
20. * default_view(self): says which windows should be open at start up
21. * legends(self): returns a string to be displayed at the bottom ot the Legend window.
22. * display_(self): says which statistics are displayed each year
23. * Field_grid(self): initial draw in the Field window
24. * Trajectory_grid(self): initial draw in the Trajectory window
25. * wallpaper(self, Window): if one wants to display different backgrounds in windows

Functions marked with ‘–’ are called from within the scenario.
Functions marked with ‘+’ are called from Group.py.
Functions marked with ‘*’ are called from Observer.py.

You may then run the scenario by choosing MyScenario.evo from the Configuration Editor.

### To create a scenario from scratch

1. Suppose you want to run a simulation of beehive. Create a new file, e.g. S_Beehive.py (or any appropriate name starting with S_) in the directory Scenarii by copying an existing scenario (pick the one that seems to resemble your own project most closely, e.g. S_SexRatio.py).
2. Customize S_Beehive.py by rewriting any functions inherited from Default_Scenario (some have been listed in the preceding section).
3. Create a Beehive.evo configuration file at an appropriate location (typically in the Expe directory). This file should include many of the parameter-value pairs that Evolife is looking for, such as PopulationSize or MutationRate.
4. You can edit the new parameter-value pairs you introduced in the .evo configuration file using the confituration editor (starter). Your parameters will be merely added at the bottom after you have loaded Beehive.evo. If you want a cleaner aspect, you should edit the appropriate .xml file loaded by starter. Then restart the Configuration Editor by executing ./starter. After setting all relevant parameters to the desired values, you can run Evolife with your scenario by clicking on [Run].

If you REALLY need to re-implement classes such as Individual, Group, Population or Observer, do the same by rewriting CustomScenario.