edu.stanford.multiagent.gamer
Class GraphicalGame

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.Game
              |
              +--edu.stanford.multiagent.gamer.GraphicalGame
Direct Known Subclasses:
CompoundGame, PolymatrixGame, RandomGraphicalGame

public abstract class GraphicalGame
extends Game

Abstract class implements the basic common features of graphical games. The graphical game may have data stored at either edges or at the nodes. If data is at the nodes, this data would be in the form of a matrix of payoffs for one players based on actions of all connected players. If the data is at the edges it would be in the form of 2 person games which are added to the node data to get the payoff.


Field Summary
protected  edu.stanford.multiagent.gamer.graphs.ALGraph graph
           
 
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
GraphicalGame()
          Constructor for new graphical games.
 
Method Summary
protected  void addEdge(int player1, int player2)
          Adds an edge from player1 to player2 but leaves the data for the edge set to null.
protected  void addEdge(int player1, int player2, edu.stanford.multiagent.gamer.DoubleTensor matrix)
          Adds an edge from player1 to player2 if the player numbers are valid, and sets the matrix at the edge to the one given.
 double getPayoff(int[] outcome, int player)
          Figures out payoff for a certain outcome by adding up a) the payoff from the matrix that is stored at the player's node if one exists b) payoffs from all of the matrices which are connected by edges to the node of a certain player, if any of those exist
protected abstract  void initGraph()
          Creates and initializes a graph of the correct type.
 void setNodeMatrix(int player, edu.stanford.multiagent.gamer.DoubleTensor matrix)
          Sets the matrix for the player's node if using the version of the graphical game representation in which the payoffs are stored in matrices at the nodes (as opposed to only on edges).
 void writeGame(java.io.PrintWriter out)
          Writes output as a graphical game.
 
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
 
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
 

Field Detail

graph

protected edu.stanford.multiagent.gamer.graphs.ALGraph graph
Constructor Detail

GraphicalGame

public GraphicalGame()
              throws java.lang.Exception
Constructor for new graphical games.

Method Detail

addEdge

protected void addEdge(int player1,
                       int player2)
                throws java.lang.Exception
Adds an edge from player1 to player2 but leaves the data for the edge set to null. Use this to add edges if the graphical game being created uses matrices at the nodes instead of at the egdes

Parameters:
player1 - the player node at which the edge should originate
player2 - the player node at which the edge should end
java.lang.Exception

addEdge

protected void addEdge(int player1,
                       int player2,
                       edu.stanford.multiagent.gamer.DoubleTensor matrix)
                throws java.lang.Exception
Adds an edge from player1 to player2 if the player numbers are valid, and sets the matrix at the edge to the one given.

Parameters:
player1 - the player node at which the edge should originate
player2 - the player node at which the edge should end
matrix - the tensor to store on the edge
Throws:
java.lang.Exception - if the tensor is invalid, if an edge from player1 to player2 already exists, or if the player numbers are invalid

setNodeMatrix

public void setNodeMatrix(int player,
                          edu.stanford.multiagent.gamer.DoubleTensor matrix)
Sets the matrix for the player's node if using the version of the graphical game representation in which the payoffs are stored in matrices at the nodes (as opposed to only on edges). The appropriate number of edges must have already been added to the graph. After this, no more edges can be added to or from this player.

Parameters:
player - the player whose node the data should be stored at
matrix - the tensor to store at this node

getPayoff

public double getPayoff(int[] outcome,
                        int player)
Figures out payoff for a certain outcome by adding up a) the payoff from the matrix that is stored at the player's node if one exists b) payoffs from all of the matrices which are connected by edges to the node of a certain player, if any of those exist

Specified by:
getPayoff in class Game
Parameters:
outcome - an array containing the actions chosen by each player
player - the player whose payoff should be returned

initGraph

protected abstract void initGraph()
                           throws java.lang.Exception
Creates and initializes a graph of the correct type. Must be implemented by each subclass and called in the initialize method after all parameters have been set in place.

java.lang.Exception

writeGame

public void writeGame(java.io.PrintWriter out)
Writes output as a graphical game. The format of this output is subject to change with future versions of GAMUT.

Overrides:
writeGame in class Game
Parameters:
out - the PrintWriter to which the output should be written