edu.stanford.multiagent.gamer
Class DispersionGame

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.Game
              |
              +--edu.stanford.multiagent.gamer.DispersionGame

public class DispersionGame
extends Game

Class implements a specific kind of dispersion game: both action symmetric and agent symmetric as defined in the dispersion games literature, also strong, and common payoff. It is not required that the number of players be equal to the number of actions. The dispersion ordering used is a full ordering where one outcome is more dispersed than another if the entropy is higher. (Other implementations could have been used, such as keeping the partial ordering or using standard deviation, but the entropy-based ordering is easy to implement and equally valid.)


Field Summary
 
Fields inherited from class edu.stanford.multiagent.gamer.Game
actions, DEFAULT_HIGH, DEFAULT_LOW, intMult, intPayoffs, players, pMaxPayoff, pMinPayoff, pNormalize, symActions
 
Fields inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
parameters
 
Constructor Summary
DispersionGame()
           
 
Method Summary
protected  void checkParameters()
          Checks if Parameter values are consistent.
 void doGenerate()
          Generate all groupings of outcomes that will have the same entropy with the given number of players and number of actions.
protected  java.lang.String getGameHelp()
          Return help screen information about the given game class.
 java.util.Vector getPayoff(int[] outcome)
          Since the game is common payoff, it is much more efficient to get all payoffs at once.
 double getPayoff(int[] outcome, int player)
          The payoff will be the same for each player, based on how dispersed the actions are as a whole.
 void initialize()
          Initialize the dispersion game by setting the number of players and the number of actions and creating the hashmap for storing entropy/payoff pairs.
 void randomizeParameters()
          Sets values of any unset parameters randomly.
 void setParameters(edu.stanford.multiagent.gamer.ParamParser p, boolean randomize)
          Sets multiple parameters at once using a ParamParser.
 
Methods inherited from class edu.stanford.multiagent.gamer.Game
generate, getAutoNormPayoff, getDescription, getHelp, getName, getNormPayoff, getNumActions, getNumActions, getNumPlayers, getOutputPayoff, getOutputPayoff, getRangeHelp, parseActions, parsePlayersActions, parsePlayersSameNumberActions, parseSameNumberActions, setDescription, setName, setNormMinAndMax, setNumActions, setNumActions, setNumPlayers, writeGame
 
Methods inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
getBooleanParameter, getDoubleParameter, getLongParameter, getParamDescription, getParameter, getParameters, getStringParameter, setParameter, setParameter, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispersionGame

public DispersionGame()
               throws java.lang.Exception
Method Detail

setParameters

public void setParameters(edu.stanford.multiagent.gamer.ParamParser p,
                          boolean randomize)
                   throws java.lang.Exception
Description copied from class: ParameterizedObject
Sets multiple parameters at once using a ParamParser.

Overrides:
setParameters in class ParameterizedObject
Parameters:
p - the ParamParser containing the parameters and their values
randomize - should be set to true if it is desired that any unset parameters be randomized
Throws:
java.lang.Exception

initialize

public void initialize()
                throws java.lang.Exception
Initialize the dispersion game by setting the number of players and the number of actions and creating the hashmap for storing entropy/payoff pairs.

Overrides:
initialize in class Game
Throws:
java.lang.Exception

getPayoff

public double getPayoff(int[] outcome,
                        int player)
The payoff will be the same for each player, based on how dispersed the actions are as a whole.

Specified by:
getPayoff in class Game
Parameters:
outcome - array of integers representing which actions have been chosen by each player
player - the player whose payoff to return

getPayoff

public java.util.Vector getPayoff(int[] outcome)
Since the game is common payoff, it is much more efficient to get all payoffs at once.

Overrides:
getPayoff in class Game
Parameters:
outcome - an array containing the action choices of all players at the given outcome

checkParameters

protected void checkParameters()
                        throws java.lang.Exception
Description copied from class: ParameterizedObject
Checks if Parameter values are consistent. Must be implemented by every non-abstract subclass of ParameterizedObject.

Specified by:
checkParameters in class ParameterizedObject
Throws:
java.lang.Exception - if anything is wrong with the parameter values

randomizeParameters

public void randomizeParameters()
Description copied from class: ParameterizedObject
Sets values of any unset parameters randomly. Can and should be overridden in subclasses to handle a non-uniform distribution and for constraints on parameters.

Overrides:
randomizeParameters in class ParameterizedObject

getGameHelp

protected java.lang.String getGameHelp()
Description copied from class: Game
Return help screen information about the given game class.

Specified by:
getGameHelp in class Game

doGenerate

public void doGenerate()
Generate all groupings of outcomes that will have the same entropy with the given number of players and number of actions. Generate a list of payoffs of length equal to the number of groups. Sort the groups by entropy and assign payoffs, always assigning higher payoffs to groups with higher entropies.

Specified by:
doGenerate in class ParameterizedObject