edu.stanford.multiagent.gamer
Class ZeroSumGame

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.Game
              |
              +--edu.stanford.multiagent.gamer.ZeroSumGame
Direct Known Subclasses:
MatchingPennies, RandomZeroSum, RockPaperScissors

public abstract class ZeroSumGame
extends Game

Abstract class used for representing a two-player zero-sum game. Implemented in a similar manner to MatrixGame except only one payoff matrix needs to be stored.


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
ZeroSumGame()
          Constructor for two-player zero-sum games.
 
Method Summary
 double getPayoff(int[] outcome, int player)
          Return the payoff for the specified player at the specified outcome.
 void initPayoffs(int a1, int a2)
          Create the matrix of payoffs.
 void setPayoff(int[] outcome, double payoff)
          Set the payoff for the first player at the given outcome.
 
Methods inherited from class edu.stanford.multiagent.gamer.Game
generate, getAutoNormPayoff, getDescription, getGameHelp, getHelp, getName, getNormPayoff, getNumActions, getNumActions, getNumPlayers, getOutputPayoff, getOutputPayoff, getPayoff, getRangeHelp, initialize, parseActions, parsePlayersActions, parsePlayersSameNumberActions, parseSameNumberActions, setDescription, setName, setNormMinAndMax, setNumActions, setNumActions, setNumPlayers, writeGame
 
Methods inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
checkParameters, doGenerate, getBooleanParameter, getDoubleParameter, getLongParameter, getParamDescription, getParameter, getParameters, getStringParameter, randomizeParameters, setParameter, setParameter, setParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZeroSumGame

public ZeroSumGame()
            throws java.lang.Exception
Constructor for two-player zero-sum games.

Method Detail

initPayoffs

public void initPayoffs(int a1,
                        int a2)
Create the matrix of payoffs.

Parameters:
a1 - the number of actions player 1 has
a2 - the number of actions player 2 has

getPayoff

public double getPayoff(int[] outcome,
                        int player)
Return the payoff for the specified player at the specified outcome.

Specified by:
getPayoff in class Game
Parameters:
outcome - an array holding the outcome choices for each player
player - the player whose action should be returned

setPayoff

public void setPayoff(int[] outcome,
                      double payoff)
Set the payoff for the first player at the given outcome. The payoff for player 2 at this outcome will be the negation of this.

Parameters:
outcome - an array holding the outcome choices for each player
payoff - the amount of the payoff