Class Centipede
- All Implemented Interfaces:
Runnable
,IBS.HasIBS
,IBS.HasIBS.DPairs
,MilestoneListener
,Features
,Features.Pairs
,HasMean
,HasMean.Fitness
,HasMean.Strategy
,HasPop2D
,HasPop2D.Fitness
,HasPop2D.Strategy
,HasPop3D
,HasPop3D.Fitness
,HasPop3D.Strategy
,HasS3
,CLOProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
The CentiMap class provides a mapping of the centipede game to a pair of \(S_3\) simplices for the first mover and second mover roles.class
The CentiMutations class provides a mutation operator for the centipede game.Nested classes/interfaces inherited from interface Features
Features.Groups, Features.Pairs, Features.Static
Nested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.Strategy
Nested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.Strategy
Nested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.Strategy
Nested classes/interfaces inherited from interface IBS.HasIBS
IBS.HasIBS.CGroups, IBS.HasIBS.CPairs, IBS.HasIBS.DGroups, IBS.HasIBS.DPairs, IBS.HasIBS.MCGroups, IBS.HasIBS.MCPairs
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) double
The benefit of cooperation, i.e.final CLOption
Command line option to set the benefit of cooperation, i.e.final CLOption
Command line option to set the cost of cooperation, i.e.final CLOption
Command line option to set the maximum number of decision nodes for the centipede game.(package private) double
The cost of cooperation, i.e.(package private) int
The number of first mover rounds.(package private) int
The number of decision nodes in the centipede game.(package private) int
The number of second mover rounds.(package private) double[][]
The payoff matrix for the first mover.(package private) double[][]
The payoff matrix for the second mover.Fields inherited from class Discrete
cloMonoStop, monoStop, mutation, species
Fields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxis, cloSpeciesUpdateRate, cloTraitColors, cloTraitDisable, cloTraitNames, competition, deathRate, defaultColor, engine, ibs, ID, interaction, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, speciesUpdateRate, structure, traitColor, traitName, trajectoryColor, VACANT
Fields inherited from interface HasS3
CORNER_LEFT, CORNER_RIGHT, CORNER_TOP, EDGE_BOTTOM, EDGE_LEFT, EDGE_RIGHT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
check()
Check all parameters.void
collectCLO
(CLOParser parser) All providers of command line options must implement this method to collect their options.Returns a string with information about the authors of the module.double
Get the benefit of cooperation, i.e.double
getCost()
Get the cost of cooperation, i.e.getKey()
Returns identifier of the active module.double
Calculates and returns the maximum payoff/score of an individual.double
Calculates and returns the minimum payoff/score of an individual.double
getMonoGameScore
(int trait) Calculate and return the payoff/score of individuals in monomorphic populations with trait/strategytype
.Gets the mutation type.double
getNodes()
Get the number of decision nodes for the centipede game.int
Gets the numberof roles that an individual can adopt.double
getPayFirst
(int meTrait, int youTrait) Returns the payoff for the first mover.double
getPaySecond
(int meTrait, int youTrait) Returns the payoff for the second mover.getS3Map
(int role) Get the map that transforms the data of the model to a 2D phase plane (projection).getTitle()
Returns title of active module, e.g.void
load()
Load new module and perform basic initializations.void
mixedScores
(int[] traitCount, double[] traitScores) Calculate the average payoff/score in a finite population with the number of each trait/strategy provided incount
for pairwise interactions.double
pairScores
(int me, int[] traitCount, double[] traitScore) Calculate and return total (accumulated) payoff/score for pairwise interactions of the focal individual with trait/strategyme
against opponents with different traits/strategies.void
setBenefit
(double benefit) Set the benefit of cooperation, i.e.void
setCost
(double cost) Set the cost of cooperation, i.e.void
setNodes
(int nNodes) Set the number of decision nodes for the centipede game.Methods inherited from class Discrete
add, getMaxMonoGameScore, getMinMonoGameScore, getMonoStop, setMonoStop, unload
Methods inherited from class Module
createGeometry, createIBSPop, getActiveTraits, getCompetitionGeometry, getDeathRate, getDependent, getGeometry, getIBSPopulation, getID, getInteractionGeometry, getMapToFitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getSpeciesUpdateRate, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacant, init, isNeutral, processColorMap, reset, run, setActiveTraits, setDeathRate, setGeometries, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setOpponent, setSpeciesUpdateRate, setTraitColors, setTraitNames, setTrajectoryColor
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface CLOProvider
adjustCLO
Methods inherited from interface Features.Pairs
isPairwise
Methods inherited from interface IBS.HasIBS
createIBS
Methods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelSettings, modelStopped, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
-
Field Details
-
nNodes
int nNodesThe number of decision nodes in the centipede game. -
cost
double costThe cost of cooperation, i.e. the costs incurring to the player when continuing the centipede game for another round. -
benefit
double benefitThe benefit of cooperation, i.e. the benefit provided to the opponent when continuing the centipede game for another round. -
payFirst
double[][] payFirstThe payoff matrix for the first mover. -
paySecond
double[][] paySecondThe payoff matrix for the second mover. -
nFirst
int nFirstThe number of first mover rounds. -
nSecond
int nSecondThe number of second mover rounds. -
cloCost
Command line option to set the cost of cooperation, i.e. the costs incurring to the player when continuing the centipede game for another round. -
cloBenefit
Command line option to set the benefit of cooperation, i.e. the benefit provided to the opponent when continuing the centipede game for another round. -
cloNodes
Command line option to set the maximum number of decision nodes for the centipede game.
-
-
Constructor Details
-
Centipede
Constructs a new instance for the Centipede module.- Parameters:
engine
- the EvoLudo engine
-
-
Method Details
-
load
public void load()Description copied from class:Module
Load new module and perform basic initializations. -
getKey
Description copied from class:Module
Returns identifier of the active module. For example, 2x2 games inTBT
return "2x2". This corresponds to the argument for the--module
option to load a particular module. The default is to use the class name. -
getAuthors
Description copied from class:Module
Returns a string with information about the authors of the module.- Overrides:
getAuthors
in classModule
- Returns:
- the names of the authors
-
getTitle
Description copied from class:Module
Returns title of active module, e.g. 2x2 games inTBT
returns "2x2 Games". -
check
public boolean check()Description copied from class:Module
Check all parameters. After this call all parameters must be consistent. If parameter adjustments require a reset then this method must returntrue
.Note: All parameter changes that don't require a reset can be made on the fly, in particular also while a model is running.
-
getNRoles
public int getNRoles()Description copied from class:Module
Gets the numberof roles that an individual can adopt. For example the role of a proposer or a responder in the Ultimatum game or the first or second movers in the Centipede game. -
getS3Map
Description copied from interface:HasS3
Get the map that transforms the data of the model to a 2D phase plane (projection). -
getMutation
Description copied from class:Module
Gets the mutation type.- Overrides:
getMutation
in classDiscrete
- Returns:
- the mutation type
-
getPayFirst
public double getPayFirst(int meTrait, int youTrait) Returns the payoff for the first mover.- Parameters:
meTrait
- the trait of the first moveryouTrait
- the trait of the second mover- Returns:
- the payoff for the first mover
-
getPaySecond
public double getPaySecond(int meTrait, int youTrait) Returns the payoff for the second mover.- Parameters:
meTrait
- the trait of the second moveryouTrait
- the trait of the first mover- Returns:
- the payoff for the second mover
-
pairScores
public double pairScores(int me, int[] traitCount, double[] traitScore) Description copied from interface:IBS.HasIBS.DPairs
Calculate and return total (accumulated) payoff/score for pairwise interactions of the focal individual with trait/strategyme
against opponents with different traits/strategies. The respective numbers of each of thenTraits
opponent traits/strategies are provided in the arraytCount
. The payoffs/scores for each of thenTraits
opponent traits/strategies must be stored and returned in the arraytScore
.Important: must be overridden and implemented in subclasses that define game interactions between pairs of individuals (
nGroup=2
,pairwise=true
), otherwise seeIBS.HasIBS.DGroups.groupScores(int[], double[])
.- Specified by:
pairScores
in interfaceIBS.HasIBS.DPairs
- Parameters:
me
- the trait index of the focal individualtraitCount
- number of opponents with each trait/strategytraitScore
- array for returning the scores of each opponent trait/strategy- Returns:
- score of focal individual
me
accumulated over all interactions
-
mixedScores
public void mixedScores(int[] traitCount, double[] traitScores) Description copied from interface:IBS.HasIBS.DPairs
Calculate the average payoff/score in a finite population with the number of each trait/strategy provided incount
for pairwise interactions. The payoffs/scores for each of thenTraits
traits/strategies must be stored and returned in the arraytraitScores
.Important: must be overridden and implemented in subclasses that define game interactions in well-mixed populations where individuals interact with everyone else. Computationally it is not feasible to cover this scenario with
IBS.HasIBS.DPairs.pairScores(int, int[], double[])
orIBS.HasIBS.DGroups.groupScores(int[], double[])
, respectively.Note: If explicit calculations of the well-mixed scores are not available, interactions with everyone in well-mixed populations should checked for and excluded with a warning in
IBS.check()
(seeCXPopulation
for an example).- Specified by:
mixedScores
in interfaceIBS.HasIBS.DPairs
- Parameters:
traitCount
- number of individuals for each trait/strategytraitScores
- array for returning the payoffs/scores of each trait/strategy
-
getMonoGameScore
public double getMonoGameScore(int trait) Description copied from class:Discrete
Calculate and return the payoff/score of individuals in monomorphic populations with trait/strategytype
.Note: Optional implementation. Returns
Double#NaN
if not defined or not implemented.- Overrides:
getMonoGameScore
in classDiscrete
- Parameters:
trait
- trait/strategy- Returns:
- payoff/score in monomorphic population with trait/strategy
type
-
getMinGameScore
public double getMinGameScore()Description copied from class:Module
Calculates and returns the minimum payoff/score of an individual. This value is important for converting payoffs/scores into probabilities, for scaling graphical output and some optimizations.- Specified by:
getMinGameScore
in classModule
- Returns:
- the minimum payoff/score
- See Also:
-
getMaxGameScore
public double getMaxGameScore()Description copied from class:Module
Calculates and returns the maximum payoff/score of an individual. This value is important for converting payoffs/scores into probabilities, for scaling graphical output and some optimizations.- Specified by:
getMaxGameScore
in classModule
- Returns:
- the maximum payoff/score
- See Also:
-
setCost
public void setCost(double cost) Set the cost of cooperation, i.e. the costs incurring to the player when continuing the centipede game for another round.- Parameters:
cost
- the cost of cooperation
-
getCost
public double getCost()Get the cost of cooperation, i.e. the costs incurring to the player when continuing the centipede game for another round.- Returns:
- the cost of cooperation
-
setBenefit
public void setBenefit(double benefit) Set the benefit of cooperation, i.e. the benefit provided to the opponent when continuing the centipede game for another round.- Parameters:
benefit
- the benefit of cooperation
-
getBenefit
public double getBenefit()Get the benefit of cooperation, i.e. the benefit provided to the opponent when continuing the centipede game for another round.- Returns:
- the benefit of cooperation
-
setNodes
public void setNodes(int nNodes) Set the number of decision nodes for the centipede game.- Parameters:
nNodes
- the number of decision nodes
-
getNodes
public double getNodes()Get the number of decision nodes for the centipede game.- Returns:
- the number of decision nodes
-
collectCLO
Description copied from interface:CLOProvider
All providers of command line options must implement this method to collect their options.Each command line option is (uniquely) identified by it's name (see
CLOption.getName()
), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, theparser
issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and callsuper.collectCLO(CLOParser)
at the end such that subclasses are able to override command line options specified in a parental class.Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.
- Specified by:
collectCLO
in interfaceCLOProvider
- Overrides:
collectCLO
in classDiscrete
- Parameters:
parser
- the reference to parser that manages command line options- See Also:
-