public class GridGame extends java.lang.Object implements DomainGenerator
SGAgentType
to use with this game, use the getStandardGridGameAgentType(burlap.oomdp.core.Domain)
static method.
JointActionModel
set for the domain is GridGameStandardMechanics
,
with a default semi-wall probability of passing through of 0.5, which is changeable with theModifier 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 |
ACTIONEAST
A constant for the name of the east action.
|
static java.lang.String |
ACTIONNOOP
A constant for the name of the no operation (do nothing) action.
|
static java.lang.String |
ACTIONNORTH
A constant for the name of the north action.
|
static java.lang.String |
ACTIONSOUTH
A constant for the name of the south action.
|
static java.lang.String |
ACTIONWEST
A constant for the name of the west action.
|
static java.lang.String |
ATTE1
A constant for the name of the first wall end position attribute.
|
static java.lang.String |
ATTE2
A constant for the name of the second wall end position attribute.
|
static java.lang.String |
ATTGT
A constant for the name of the goal type attribute.
|
static java.lang.String |
ATTP
A constant for the name of the attribute for defining the walls position along its orthogonal direction.
|
static java.lang.String |
ATTPN
A constant for the name of the player number attribute.
|
static java.lang.String |
ATTWT
A constant for the name of the wall type attribute.
|
static java.lang.String |
ATTX
A constant for the name of the x position attribute
|
static java.lang.String |
ATTY
A constant for the name of the y position attribute
|
static java.lang.String |
CLASSAGENT
A constant for the name of the agent class.
|
static java.lang.String |
CLASSDIMHWALL
A constant for the name of the horizontal wall class.
|
static java.lang.String |
CLASSDIMVWALL
A constant for the name of the vertical wall class.
|
static java.lang.String |
CLASSGOAL
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 |
PFINPGOAL
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 |
PFINUGOAL
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.
|
Constructor and Description |
---|
GridGame() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addNObjects(Domain d,
State s,
java.lang.String className,
int n)
AddsN objects of a specific object class to a state object
|
Domain |
generateDomain()
Returns a newly instanced Domain object
|
static State |
getCleanState(Domain d,
int na,
int ng,
int nhw,
int nvw,
int width,
int height)
Returns a state with with the specified number of objects for each object class and with the specified boundary of
the playing area.
|
static State |
getCorrdinationGameInitialState(Domain d)
Returns the initial state for a classic coordination game, where the agent's personal goals are on opposite sides.
|
static State |
getFriendFoeInitialState(Domain d)
Returns the initial state for Friend Foe game.
|
static State |
getIncredibleInitialState(Domain d)
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(Domain d)
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(Domain d)
Returns the initial state for a simple game in which both players can win without interfering with one another.
|
static SGAgentType |
getStandardGridGameAgentType(Domain domain)
Creates and returns a standard
SGAgentType for grid games. |
static State |
getTurkeyInitialState(Domain d) |
static void |
main(java.lang.String[] args)
Creates a visual explorer for a simple domain with two agents in it.
|
static void |
setAgent(State s,
int i,
int x,
int y,
int pn)
Sets an agent's attribute values
|
static void |
setBoundaryWalls(State s,
int w,
int h)
Sets boundary walls of a domain.
|
static void |
setGoal(State s,
int i,
int x,
int y,
int gt)
Sets a goal objects attribute values
|
static void |
setHorizontalWall(State s,
int i,
int p,
int e1,
int e2,
int wt)
Sets the attribute values for a horizontal wall
|
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.
|
static void |
setVerticalWall(State s,
int i,
int p,
int e1,
int e2,
int wt)
Sets the attribute values for a vertical wall
|
static void |
setWallInstance(ObjectInstance w,
int p,
int e1,
int e2,
int wt)
Sets the attribute values for a wall instance
|
public static final java.lang.String ATTX
public static final java.lang.String ATTY
public static final java.lang.String ATTPN
public static final java.lang.String ATTGT
public static final java.lang.String ATTE1
public static final java.lang.String ATTE2
public static final java.lang.String ATTP
public static final java.lang.String ATTWT
public static final java.lang.String CLASSAGENT
public static final java.lang.String CLASSGOAL
public static final java.lang.String CLASSDIMHWALL
public static final java.lang.String CLASSDIMVWALL
public static final java.lang.String ACTIONNORTH
public static final java.lang.String ACTIONSOUTH
public static final java.lang.String ACTIONEAST
public static final java.lang.String ACTIONWEST
public static final java.lang.String ACTIONNOOP
public static final java.lang.String PFINUGOAL
public static final java.lang.String PFINPGOAL
protected int maxDim
protected int maxPlyrs
protected int maxGT
protected int maxWT
protected double semiWallProb
public static void main(java.lang.String[] args)
If "t" is passed as an argument then a terminal explorer is used instead.
args
- 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 Domain generateDomain()
DomainGenerator
generateDomain
in interface DomainGenerator
public static State getCleanState(Domain d, int na, int ng, int nhw, int nvw, int width, int height)
d
- the domain object of the grid worldna
- the number of agents/playersng
- the number of goal objectsnhw
- the number of horizontal wallsnvw
- the number of vertical wallswidth
- the width of the playing areaheight
- the height of the playing areapublic static State getSimpleGameInitialState(Domain d)
d
- the grid games domain objectpublic static State getCorrdinationGameInitialState(Domain d)
d
- the grid games domain objectpublic static State getPrisonersDilemmaInitialState(Domain d)
d
- the grid game's domain objectpublic static State getFriendFoeInitialState(Domain d)
d
- the grid game's domain objectpublic static State getIncredibleInitialState(Domain d)
d
- the grid game's domain objectprotected static void addNObjects(Domain d, State s, java.lang.String className, int n)
d
- the domain of the object classess
- the state to which the objects of the specified class should be addedclassName
- the name of the object class for which to create object instancesn
- the number of object instances to createpublic static void setAgent(State s, int i, int x, int y, int pn)
s
- the state in which the agent existsi
- indicates the ith agent object whose values should be setx
- the x position of the agenty
- the y position of the agentpn
- the player number of the agentpublic static void setGoal(State s, int i, int x, int y, int gt)
s
- the state in which the goal existsi
- indicates the ith goal object whose values should be setx
- the x position of the goaly
- the y position of the goalgt
- the goal typepublic static void setBoundaryWalls(State 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 void setWallInstance(ObjectInstance w, int p, int e1, int e2, int wt)
w
- the wall instance to setp
- the orthogonal position of the wall instancee1
- the first end point of the walle2
- the second end point of the wallwt
- the type of the wallpublic static void setVerticalWall(State s, int i, int p, int e1, int e2, int wt)
s
- the state in which the wall exitsi
- indicates the ith vertical wall instance whose values should be setp
- the x position of the vertical walle1
- the bottom end point of the walle2
- the top end point of the wallwt
- the type of the wallpublic static void setHorizontalWall(State s, int i, int p, int e1, int e2, int wt)
s
- the state in which the wall exitsi
- indicates the ith horizontal wall instance whose values should be setp
- the y position of the vertical walle1
- the left end point of the walle2
- the right end point of the wallwt
- the type of the wall (0 is solid, 1 is semi)public static SGAgentType getStandardGridGameAgentType(Domain 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.