edu.stanford.multiagent.gamer
Class ArmsRace

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

public class ArmsRace
extends Game

Return an instance of a discretized Arms Race game using user specified functions. For now it is left to the user to make sure that the C function is smooth and the B function is smooth and concave. Although the arms races game could be extended to more that two players, we will limit it at two as is the general case that is studied in economics.


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
ArmsRace()
           
 
Method Summary
protected  void checkParameters()
          Make sure that the parameters are in the proper range
 void doGenerate()
          Generates the functions.
protected  java.lang.String getGameHelp()
          Return help screen information about the given game class.
 double getPayoff(int[] outcome, int player)
          Returns the payoff for the given player in the given outcome.
 void initialize()
          Initializes using preset parameter values
 void randomizeParameters()
          Randomize the low and high actions and functions
 void setParameters(edu.stanford.multiagent.gamer.ParamParser p, boolean randomize)
          Set the parameters for the game itself, and parse and set the parameters for the C and B functions.
 
Methods inherited from class edu.stanford.multiagent.gamer.Game
generate, getAutoNormPayoff, getDescription, getHelp, getName, getNormPayoff, getNumActions, getNumActions, getNumPlayers, getOutputPayoff, getOutputPayoff, getPayoff, 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

ArmsRace

public ArmsRace()
         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, and parse and set the parameters for the C and B functions.

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

randomizeParameters

public void randomizeParameters()
Randomize the low and high actions and functions

Overrides:
randomizeParameters in class ParameterizedObject

checkParameters

protected void checkParameters()
                        throws java.lang.Exception
Make sure that the parameters are in the proper range

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

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

getPayoff

public double getPayoff(int[] outcome,
                        int player)
Returns the payoff for the given player in the given outcome. If x is the level of arms the player has chosen and y is the level the opponent has chosen then the payoff for the player is: -C(x) + B(x-y) Note that since our actions always begin at 1, the y values are really the action + the low action value - 1.

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

doGenerate

public void doGenerate()
Generates the functions.

Specified by:
doGenerate in class ParameterizedObject