→ summary
******************************************************************************************
Module Evolife.Scenarii.Default_Scenario:
========================================
EVOLIFE: Default Scenario:
Determines how individuals acquire
their score, either by themselves or through interactions Evolife scenarii may rewrite several functions defined here :
(those marked with ‘+’ are called from ‘Group.py')
(those marked with ‘o’ are called from ‘Observer.py')
- initialization(self): allows to define local variables
- genemap(self): initialises the genes on the gene map (see ‘Genetic_map.py')
- phenemap(self): defines a list of phenotypic character names (see ‘Phenotype.py')
+ season(self, year, members): makes periodic actions like resetting parameters
+ behaviour(self, BestIndiv, AvgIndiv): defines a behaviour to be displayed
+ life_game(self, members): defines a round of interactions - calls the five following functions
- start_game(self, members): group-level initialization before starting interactions
- prepare(self, indiv): individual initialization before starting interactions
- interaction(self, Indiv, Partner): defines a single interaction
- partner(self, Indiv, members): select a partner among ‘members’ that will interact with ‘Indiv’
- end_game(self, members): an occasion for a closing round after all interactions
- evaluation(self, Indiv): defines how the score of an individual is computed
- lives(self, members): converts scores into life points
+ couples(self, members): returns a list of couples for procreation (individuals may appear in several couples!)- Calls the following functions:
- parenthood(self, RankedCandidates, Def_Nb_Children): Determines the number of children depending on rank
- parents(self, candidates): selects two parents from a list of candidates (candidate = (indiv, NbOfPotentialChildren))
+ new_agent(self, child, parents): initializes newborns
+ remove_agent(self, agent): action to be performed when an agent dies
+ update_positions(self, members, groupID): assigns a position to agents
o default_view(self): says which windows should be open at start up
o legends(self): returns a string to be displayed at the bottom ot the Legend window.
o display_(self): says which statistics are displayed each year
o def Field_grid(self): initial draw in the Field window
o def Trajectory_grid(self): initial draw in the Trajectory window
o wallpaper(self, Window): if one wants to display different backgrounds in windows
************
******************************************************************************************
**************************************************************************************
Class Default_Scenario: inherits from Evolife.Scenarii.Parameters.Parameters, Evolife.Genetics.Genetic_map.Genetic_map
======================
All functions defined here can be
overloaded in specific scenarii (see module doc)
**************************************************************************************
----------------------------------------------------------------------------------
Method Default_Scenario.__init__:
================================
Loads parameters, sets gene map and calls local initialization.
----------------------------------------------------------------------------------
Arguments:
. Name
. CfgFile
----------------------------------------------------------------------------------
Method Default_Scenario.initialization:
======================================
local initialization, to be overloaded
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.genemap:
===============================
Defines the name of genes and their position on the DNA.
Accepted syntax:
[’genename1’, ‘genename2’,...]: lengths and coding are retrieved from configuration.
[('genename1’, 8), ('genename2’, 4),...]: numbers give lengths in bits; coding is retrieved from configuration.
[('genename1’, 8, ‘Weighted'), ('genename2’, 4, ‘Unweighted'),...]: coding can be ‘Weighted’, ‘Unweighted’, ‘Gray’, ‘NoCoding’.
Note that ‘Unweighted’ is unsuitable to explore large space.
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.phenemap:
================================
Defines the set of non inheritable characteristics
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.behaviour:
=================================
returns information about the phenotype of a given individual
(best individual or fictitious individual with average genome)
for display purposes (e.g. a trajectory in a maze)
----------------------------------------------------------------------------------
Arguments:
. best_individual
. avg_individual
----------------------------------------------------------------------------------
Method Default_Scenario.prepare:
===============================
defines what is to be done at the individual level before interactions
occur - Used in ‘start_game’
----------------------------------------------------------------------------------
Arguments:
. indiv
----------------------------------------------------------------------------------
Method Default_Scenario.start_game:
==================================
defines what is to be done at the group level each year
before interactions occur - Used in ‘life_game’
----------------------------------------------------------------------------------
Arguments:
. members
----------------------------------------------------------------------------------
Method Default_Scenario.evaluation:
==================================
Implements the computation of individuals’ scores - - Used in ‘life_game’
----------------------------------------------------------------------------------
Arguments:
. indiv
----------------------------------------------------------------------------------
Method Default_Scenario.partner:
===============================
Decides whom to interact with - Used in ‘life_game’
----------------------------------------------------------------------------------
Arguments:
. indiv
. members
----------------------------------------------------------------------------------
Method Default_Scenario.interaction:
===================================
Nothing by default - Used in ‘life_game’
----------------------------------------------------------------------------------
Arguments:
. indiv
. partner
----------------------------------------------------------------------------------
Method Default_Scenario.end_game:
================================
defines what to do at the group level once all interactions
have occurred - Used in ‘life_game’
----------------------------------------------------------------------------------
Arguments:
. members
----------------------------------------------------------------------------------
Method Default_Scenario.life_game:
=================================
Life games (or their components) are defined in specific scenarii
life_games calls:
- start_game (which calls ‘prepare')
- interaction (which calls ‘partner')
- end_game
- evaluation
- lives
----------------------------------------------------------------------------------
Arguments:
. members
----------------------------------------------------------------------------------
Method Default_Scenario.lives:
=============================
converts scores into life points
----------------------------------------------------------------------------------
Arguments:
. members
----------------------------------------------------------------------------------
Method Default_Scenario.season:
==============================
This function is called at the beginning of each year
----------------------------------------------------------------------------------
Arguments:
. year
. members
----------------------------------------------------------------------------------
Method Default_Scenario.parenthood:
==================================
Determines the number of children that would-be parents may have
depending on their rank
----------------------------------------------------------------------------------
Arguments:
. RankedCandidates
. Def_Nb_Children
----------------------------------------------------------------------------------
Method Default_Scenario.parents:
===============================
Selects one couple from candidates.
Candidates are (indiv, NbChildren) pairs, where NbChildren indicates the number of
children that indiv can still have
----------------------------------------------------------------------------------
Arguments:
. candidates
----------------------------------------------------------------------------------
Method Default_Scenario.couples:
===============================
Returns a set of couples that will beget newborns
Note that a given individual may appear several times
By default, the probability for an individual to be in a
couple (and thus to have a child) decreases with its rank
in ‘members’
----------------------------------------------------------------------------------
Arguments:
. members
. nb_children
----------------------------------------------------------------------------------
Method Default_Scenario.new_agent:
=================================
initializes newborns - parents==None when the population is created
----------------------------------------------------------------------------------
Arguments:
. child
. parents
----------------------------------------------------------------------------------
Method Default_Scenario.remove_agent:
====================================
action to be performed when an agent dies
----------------------------------------------------------------------------------
Arguments:
. agent
----------------------------------------------------------------------------------
Method Default_Scenario.update_positions:
========================================
Allows to define spatial coordinates for individuals.
These positions are displayed in the Field window.
Coordinates are typically (x,y,c) where c (optional)
is the colour representing the agent
----------------------------------------------------------------------------------
Arguments:
. members
. groupLocation
----------------------------------------------------------------------------------
Method Default_Scenario.default_view:
====================================
Defines which windows should be open when the program starts
Example: [’Genomes’, ‘Field’, ('Trajectories’, 320), ('Network’, 500, 200)]
optional numbers provide width and height
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.legends:
===============================
The returned string will be displayed at the bottom ot the Legend window.
Useful to describe what is to be seen in the various windows.
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.display_:
================================
Defines what is to be displayed. It offers the possibility
of plotting the evolution through time of the best score,
the average score, any locally defined value,
and the average value of the various genes and phenes.
It should return a list of pairs (C, X) or triples (C, X, L)
where C is the curve colour (colour name or number)
and X can be ‘best’, ‘average’, ‘ALocalQuantity’
(where ALocalQuantity is a local variable)
or any gene name defined in genemap
or any phene defined in phenemap.
L (optional) is a legend string
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.wallpaper:
=================================
displays background image or colour when the window is created
----------------------------------------------------------------------------------
Arguments:
. Window
----------------------------------------------------------------------------------
Method Default_Scenario.Field_grid:
==================================
returns a list of graphic orders for initial display on the Field window
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Method Default_Scenario.Trajectory_grid:
=======================================
returns a list of graphic orders for initial display on the Trajectory window
----------------------------------------------------------------------------------
Back to Evolife