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

The Centipede class provides an EvoLudo module for the centipede game.
  • Field Details

    • nNodes

      int nNodes
      The number of decision nodes in the centipede game.
    • cost

      double cost
      The cost of cooperation, i.e. the costs incurring to the player when continuing the centipede game for another round.
    • benefit

      double benefit
      The benefit of cooperation, i.e. the benefit provided to the opponent when continuing the centipede game for another round.
    • payFirst

      double[][] payFirst
      The payoff matrix for the first mover.
    • paySecond

      double[][] paySecond
      The payoff matrix for the second mover.
    • nFirst

      int nFirst
      The number of first mover rounds.
    • nSecond

      int nSecond
      The number of second mover rounds.
    • cloCost

      public final CLOption 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

      public final CLOption 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

      public final CLOption cloNodes
      Command line option to set the maximum number of decision nodes for the centipede game.
  • Constructor Details

    • Centipede

      public Centipede(EvoLudo engine)
      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.
      Overrides:
      load in class Discrete
      See Also:
    • getKey

      public String getKey()
      Description copied from class: Module
      Returns identifier of the active module. For example, 2x2 games in TBT return "2x2". This corresponds to the argument for the --module option to load a particular module. The default is to use the class name.
      Overrides:
      getKey in class Module
      Returns:
      the identifying key of this module
    • getAuthors

      public String getAuthors()
      Description copied from class: Module
      Returns a string with information about the authors of the module.
      Overrides:
      getAuthors in class Module
      Returns:
      the names of the authors
    • getTitle

      public String getTitle()
      Description copied from class: Module
      Returns title of active module, e.g. 2x2 games in TBT returns "2x2 Games".
      Specified by:
      getTitle in class Module
      Returns:
      the title of active module
    • 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 return true.

      Note: All parameter changes that don't require a reset can be made on the fly, in particular also while a model is running.

      Overrides:
      check in class Module
      Returns:
      true to trigger reset
      See Also:
    • 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.
      Overrides:
      getNRoles in class Module
      Returns:
      the number of roles of an individual
    • getS3Map

      public S3Map getS3Map(int role)
      Description copied from interface: HasS3
      Get the map that transforms the data of the model to a 2D phase plane (projection).
      Specified by:
      getS3Map in interface HasS3
      Parameters:
      role - the role of the players
      Returns:
      the map
    • getMutation

      public Mutation.Discrete getMutation()
      Description copied from class: Module
      Gets the mutation type.
      Overrides:
      getMutation in class Discrete
      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 mover
      youTrait - 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 mover
      youTrait - 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/strategy me against opponents with different traits/strategies. The respective numbers of each of the nTraits opponent traits/strategies are provided in the array tCount. The payoffs/scores for each of the nTraits opponent traits/strategies must be stored and returned in the array tScore.

      Important: must be overridden and implemented in subclasses that define game interactions between pairs of individuals (nGroup=2, pairwise=true), otherwise see IBS.HasIBS.DGroups.groupScores(int[], double[]).

      Specified by:
      pairScores in interface IBS.HasIBS.DPairs
      Parameters:
      me - the trait index of the focal individual
      traitCount - number of opponents with each trait/strategy
      traitScore - 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 in count for pairwise interactions. The payoffs/scores for each of the nTraits traits/strategies must be stored and returned in the array traitScores.

      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[]) or IBS.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() (see CXPopulation for an example).

      Specified by:
      mixedScores in interface IBS.HasIBS.DPairs
      Parameters:
      traitCount - number of individuals for each trait/strategy
      traitScores - 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/strategy type.

      Note: Optional implementation. Returns Double#NaN if not defined or not implemented.

      Overrides:
      getMonoGameScore in class Discrete
      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 class Module
      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 class Module
      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

      public void collectCLO(CLOParser parser)
      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, the parser issues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and call super.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 interface CLOProvider
      Overrides:
      collectCLO in class Discrete
      Parameters:
      parser - the reference to parser that manages command line options
      See Also: