public class GridGame extends java.lang.Object implements DomainGenerator
SGAgentType
to use with this game, use the getStandardGridGameAgentType(SGDomain)
static method.
In this domain, there is also an OO-MDP object class for 1-dimensional walls (both for horizontal walls or vertical walls). Each wall can take on a different type; a solid wall that can never be passed (type 0), and a semi-wall, can be passed with some stochastic probability (type 1). Finally, there is also an OO-MDP class for goal locations, which also have different types. There is a type that can be indicated as a universal goal/reward location for all agents (type 0), and type that is only useful to each individual agent (type i is a personal goal for player i-1).
The JointModel
set for the domain is GridGameStandardMechanics
,
with a default semi-wall probability of passing through of 0.5, which is changeable with the
Modifier and Type | Class and Description |
---|---|
static class |
GridGame.GGJointRewardFunction
Specifies goal rewards and default rewards for agents.
|
static class |
GridGame.GGTerminalFunction
Causes termination when any agent reaches a personal or universal goal location.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTION_EAST
A constant for the name of the east action.
|
static java.lang.String |
ACTION_NOOP
A constant for the name of the no operation (do nothing) action.
|
static java.lang.String |
ACTION_NORTH
A constant for the name of the north action.
|
static java.lang.String |
ACTION_SOUTH
A constant for the name of the south action.
|
static java.lang.String |
ACTION_WEST
A constant for the name of the west action.
|
static java.lang.String |
CLASS_AGENT
A constant for the name of the agent class.
|
static java.lang.String |
CLASS_DIM_H_WALL
A constant for the name of the horizontal wall class.
|
static java.lang.String |
CLASS_DIM_V_WALL
A constant for the name of the vertical wall class.
|
static java.lang.String |
CLASS_GOAL
A constant for the name of the goal class.
|
protected int |
maxDim
The width and height of the world.
|
protected int |
maxGT
The number of goal types
|
protected int |
maxPlyrs
The maximum number of players that can be in the game
|
protected int |
maxWT
The number of wall types
|
static java.lang.String |
PF_IN_P_GOAL
A constant for the name of a propositional function that evaluates whether an agent is in a personal goal location for just them.
|
static java.lang.String |
PF_IN_U_GOAL
A constant for the name of a propositional function that evaluates whether an agent is in a universal goal location.
|
protected double |
semiWallProb
The probability that an agent will pass through a semi-wall.
|
static java.lang.String |
VAR_E1
A constant for the name of the first wall end position attribute.
|
static java.lang.String |
VAR_E2
A constant for the name of the second wall end position attribute.
|
static java.lang.String |
VAR_GT
A constant for the name of the goal type attribute.
|
static java.lang.String |
VAR_PN
A constant for the name of the player number attribute.
|
static java.lang.String |
VAR_POS
A constant for the name of the attribute for defining the walls position along its orthogonal direction.
|
static java.lang.String |
VAR_WT
A constant for the name of the wall type attribute.
|
static java.lang.String |
VAR_X
A constant for the name of the x position attribute
|
static java.lang.String |
VAR_Y
A constant for the name of the y position attribute
|
Constructor and Description |
---|
GridGame() |
Modifier and Type | Method and Description |
---|---|
OOSGDomain |
generateDomain()
Returns a newly instanced Domain object
|
static State |
getCorrdinationGameInitialState()
Returns the initial state for a classic coordination game, where the agent's personal goals are on opposite sides.
|
static State |
getFriendFoeInitialState()
Returns the initial state for Friend Foe game.
|
static State |
getIncredibleInitialState()
Returns the initial state for the Incredible game (a game in which player 0 can give an incredible threat).
|
int |
getMaxDim()
Returns the maximum dimension of the world; it's width and height.
|
int |
getMaxGT()
Returns the maximum goal types
|
int |
getMaxPlyrs()
Returns the max number of players
|
int |
getMaxWT()
Returns the maximum number of wall types
|
static State |
getPrisonersDilemmaInitialState()
Returns the initial state for a classic prisoner's dilemma formulated in a Grid Game.
|
double |
getSemiWallProb()
Returns the probability that an agent can pass through a semi-wall.
|
static State |
getSimpleGameInitialState()
Returns the initial state for a simple game in which both players can win without interfering with one another.
|
static SGAgentType |
getStandardGridGameAgentType(SGDomain domain)
Creates and returns a standard
SGAgentType for grid games. |
static State |
getTurkeyInitialState() |
static void |
main(java.lang.String[] args)
Creates a visual explorer for a simple domain with two agents in it.
|
static void |
setBoundaryWalls(GenericOOState s,
int w,
int h)
/**
Sets boundary walls of a domain.
|
void |
setMaxDim(int maxDim)
Sets the maximum dimension of the world; it's width and height.
|
void |
setMaxGT(int maxGT)
Sets the maximum goal types
|
void |
setMaxPlyrs(int maxPlyrs)
Sets the max number of players
|
void |
setMaxWT(int maxWT)
Sets the maximum number of wall types
|
void |
setSemiWallPassableProbability(double p)
Sets the probability that an agent can pass through a semi-wall.
|
public static final java.lang.String VAR_X
public static final java.lang.String VAR_Y
public static final java.lang.String VAR_PN
public static final java.lang.String VAR_GT
public static final java.lang.String VAR_E1
public static final java.lang.String VAR_E2
public static final java.lang.String VAR_POS
public static final java.lang.String VAR_WT
public static final java.lang.String CLASS_AGENT
public static final java.lang.String CLASS_GOAL
public static final java.lang.String CLASS_DIM_H_WALL
public static final java.lang.String CLASS_DIM_V_WALL
public static final java.lang.String ACTION_NORTH
public static final java.lang.String ACTION_SOUTH
public static final java.lang.String ACTION_EAST
public static final java.lang.String ACTION_WEST
public static final java.lang.String ACTION_NOOP
public static final java.lang.String PF_IN_U_GOAL
public static final java.lang.String PF_IN_P_GOAL
protected int maxDim
protected int maxPlyrs
protected int maxGT
protected int maxWT
protected double semiWallProb
public int getMaxDim()
public void setMaxDim(int maxDim)
maxDim
- the maximum dimension of the world; it's width and height.public int getMaxPlyrs()
public void setMaxPlyrs(int maxPlyrs)
maxPlyrs
- the max number of playerspublic int getMaxGT()
public void setMaxGT(int maxGT)
maxGT
- the maximum goal typespublic int getMaxWT()
public void setMaxWT(int maxWT)
maxWT
- the maximum number of wall typespublic void setSemiWallPassableProbability(double p)
p
- the probability that an agent will pass through a semi-wall.public double getSemiWallProb()
public OOSGDomain generateDomain()
DomainGenerator
generateDomain
in interface DomainGenerator
public static State getSimpleGameInitialState()
public static State getCorrdinationGameInitialState()
public static State getPrisonersDilemmaInitialState()
public static State getFriendFoeInitialState()
public static State getIncredibleInitialState()
public static State getTurkeyInitialState()
public static void setBoundaryWalls(GenericOOState s, int w, int h)
s
- the state in which the walls should be addedw
- the width of the playing fieldh
- the height of the playing fieldpublic static SGAgentType getStandardGridGameAgentType(SGDomain domain)
SGAgentType
for grid games. This SGAgentType
is assigned the type name "agent", grid game OO-MDP object class for "agent", and has its action space set to all possible actions in the grid game domain.
Typically, all agents in a grid game should be assigned to the same type.domain
- the domain object of the grid game.SGAgentType
that typically all SGAgent
's of the grid game should play as.public static void main(java.lang.String[] args)
If "t" is passed as an argument then a terminal explorer is used instead.
args
- command line args