edu.stanford.multiagent.gamer
Class CongestionGame

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

public class CongestionGame
extends Game

Class implements a congestion game in which there is a set of "facilities" and each player chooses some subset of these. The payoffs for players are based only on which facilities they have chosen and how many other players have chosen the same facilities.


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
CongestionGame()
           
 
Method Summary
protected  void checkParameters()
          Checks if Parameter values are consistent.
protected  boolean didChooseFac(long action, int fac)
          Returns true if facility fac is selected for action act.
 void doGenerate()
          Generate all of the payoff functions for each player for each facility
protected  java.lang.String getGameHelp()
          Return help screen information about the given game class.
 java.util.Vector getPayoff(int[] outcome)
          It is more efficient to calculate all payoffs for all players in a given outcome at once since the number of players who have chosen each facility will only have to be calculated once.
 double getPayoff(int[] outcome, int player)
          Return the payoff for a given player at a given outcome.
 void initialize()
          Initializes using preset parameter values
protected  void initializeFunctionArray()
          Create the array of functions and initialize them all with the appropriate parameters.
 void randomizeParameters()
          Sets values of any unset parameters randomly.
 void setParameters(edu.stanford.multiagent.gamer.ParamParser p, boolean randomize)
          Set the parameters for the game itself.
 
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

CongestionGame

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

setParameters

public void setParameters(edu.stanford.multiagent.gamer.ParamParser p,
                          boolean randomize)
                   throws java.lang.Exception
Set the parameters for the game itself. The parameters for the payoff functions will be set later.

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
Description copied from class: Game
Initializes using preset parameter values

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

initializeFunctionArray

protected void initializeFunctionArray()
Create the array of functions and initialize them all with the appropriate parameters.


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

didChooseFac

protected boolean didChooseFac(long action,
                               int fac)
Returns true if facility fac is selected for action act. Treats numbers as if they are in binary and the digits set to 1 are facitilies, only is off by 1 since it is not legal for an action to consist of the empty set.


getPayoff

public double getPayoff(int[] outcome,
                        int player)
Return the payoff for a given player at a given outcome. This payoff is based on the facilities in the subset the player has chosen and the number of other players who have chosen each of these facilities.

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)
It is more efficient to calculate all payoffs for all players in a given outcome at once since the number of players who have chosen each facility will only have to be calculated once.

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

doGenerate

public void doGenerate()
Generate all of the payoff functions for each player for each facility

Specified by:
doGenerate in class ParameterizedObject