|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.repeatedgames.rgsolve.games.StageGameMethods
public class StageGameMethods
This class contains helper methods for manipulating games and performing basic operations on them
Field Summary | |
---|---|
static int |
PLAYER_1
index for player 1 in best response methods |
static int |
PLAYER_2
index for player 2 in best response methods |
static int[] |
PLAYERS
indexes for players |
Constructor Summary | |
---|---|
private |
StageGameMethods()
private constructor |
Method Summary | |
---|---|
static java.util.List<GameExtremePoint> |
getFeasibleSetHull(Game gm,
AlgoParameters params,
boolean doMultiThread)
Computes and returns the convex hull of the set of feasible stage payoffs in the game gm . |
static Fraction[][][] |
getFractionalPayoffs(Game game)
Converts game payoffs into Fractions (from reals/doubles) |
static Point |
getMaximumPayoffs(Game game)
|
static Point |
getMinimumPayoffs(Game game)
Returns the minimum feasible payoffs to each player as a Point of the game game |
static Point |
getMinMax(Game game)
Returns the minmax payoffs as a Point of the game game |
static double[][][] |
getPayoffArray(Game game)
Returns a double[][][] representation
of the stage payoffs, with [i-1][a1][a2] denoting the
payoff to player i in {PLAYER_1, PLAYER_2} given action (a1,a2) |
static Point[] |
getPointArray(Game game)
Returns an array of points representing the feasible payoffs in this game. |
static int[] |
getStaticBestResponse(Game gm,
int player,
boolean doMulti)
Returns the static best response vector for player i, where BR[a] is the best response of i to action a by player j = (-i). |
private static void |
getStaticBestResponseFrom(Game gm,
int start,
int end,
int player,
int[] BR)
Helper method that calculates the best responses for player player in the game game in response
to actions start through end of the
other player, and stores them in the array BR /
Note: there could be multiple BRs, but we only care about BRs
for defection payoffs and therefore choose a unique BR. |
static boolean[][] |
getUsableActions(Game game)
Converts the BitSet of usable actions in
the game game to a boolean[][]
representation |
static void |
showLatexTable(java.lang.String gameName,
Game gm)
Shows a JFrame with the game in LaTeX table format |
static BimatrixGame |
toBimatrixGame(Game gm)
This method converts any subclass of Game
into a BimatrixGame , storing payoffs as
double[][] arrays. |
static BimatrixGame |
toBimatrixGame(Game gm,
int m1,
int m2)
Converts the game gm to an m1 x m2
dimension BimatrixGame , truncating or padding gm
as necessary. |
static java.lang.String |
toLatexTable(Game gm,
int numDigits)
Returns the stage game as a normal-form table in LaTeX format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PLAYER_1
public static final int PLAYER_2
public static final int[] PLAYERS
Constructor Detail |
---|
private StageGameMethods()
Method Detail |
---|
public static Point[] getPointArray(Game game)
game
-
public static Point getMinMax(Game game)
Point
of the game game
game
-
public static Point getMinimumPayoffs(Game game)
Point
of the game game
game
-
public static Fraction[][][] getFractionalPayoffs(Game game)
game
-
public static double[][][] getPayoffArray(Game game)
double[][][]
representation
of the stage payoffs, with [i-1][a1][a2] denoting the
payoff to player i in {PLAYER_1, PLAYER_2} given action (a1,a2)
game
-
public static boolean[][] getUsableActions(Game game)
BitSet
of usable actions in
the game game
to a boolean[][]
representation
game
-
boolean[][]
representing usable actions in this gamepublic static BimatrixGame toBimatrixGame(Game gm)
Game
into a BimatrixGame
, storing payoffs as
double[][]
arrays.
gm
- the game to be converted
BimatrixGame
representation of gmpublic static BimatrixGame toBimatrixGame(Game gm, int m1, int m2)
gm
to an m1
x m2
dimension BimatrixGame
, truncating or padding gm
as necessary.
gm
- the gamem1
- number of player 1 actionsm2
- number of player 2 actions
BimatrixGame
representation of gmpublic static java.util.List<GameExtremePoint> getFeasibleSetHull(Game gm, AlgoParameters params, boolean doMultiThread) throws java.lang.Exception
gm
. Returns an ArrayList of GameExtremePoints sorted
counter-clockwise.
gm
- the gameparams
- parameters to use in convex hull operationdoMultiThread
- whether the method should try to parallelize the task
java.lang.Exception
public static int[] getStaticBestResponse(Game gm, int player, boolean doMulti)
gm
- the gameplayer
- the player to calculate best responses for (PLAYER_1
is player 1, etc.)doMulti
- should the method try to multi-thread?
private static void getStaticBestResponseFrom(Game gm, int start, int end, int player, int[] BR)
player
in the game game
in response
to actions start
through end
of the
other player, and stores them in the array BR
/
Note: there could be multiple BRs, but we only care about BRs
for defection payoffs and therefore choose a unique BR.
gm
- start
- end
- player
- BR
- public static java.lang.String toLatexTable(Game gm, int numDigits)
gm
- the gamenumDigits
- output digits
public static void showLatexTable(java.lang.String gameName, Game gm)
gameName
- the name of the gamegm
- the gamenumDigits
- output digitspublic static Point getMaximumPayoffs(Game game)
game
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |