public class GridGameStandardMechanics extends java.lang.Object implements FullJointModel
FullJointModel.Helper
Constructor and Description |
---|
GridGameStandardMechanics(Domain d)
Initializes the mechanics for the given domain and sets the semi-wall pass through probability to 0.5;
|
GridGameStandardMechanics(Domain d,
double semiWallPassThroughProb)
Initializes the mechanics for the given domain and sets the semi-wall pass through probability to semiWallPassThroughProb.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
agentName(int agentNum,
OOState s) |
protected boolean |
agentsEqual(OOState s1,
OOState s2)
Returns true if the agent objects between these two states are equal
|
protected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 |
attemptedDelta(java.lang.String actionName)
Returns the attempted change in position by the agent for the given action.
|
protected java.util.List<StateTransitionProb> |
combineDuplicateTransitionProbabilities(java.util.List<StateTransitionProb> srcTPs)
Iterates through a list of transition probability objects and combines any that refer to the same state
|
protected boolean |
crossesWall(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta,
ObjectInstance w,
boolean vertical)
Returns true if the agent would cross a given wall instance given a movement attempt.
|
protected void |
generateAllLocationSetsHelper(java.util.List<java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob>> locOutcomes,
int i,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2[] locArray,
double stackedProb,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> discovered)
This method will recursively generate all possible joint location outcomes for a list of possible outcomes for each agent
|
protected void |
generateAllPossibleCollisionWinnerAssignments(java.util.List<java.util.List<java.lang.Integer>> collisionLists,
int i,
int[] assignment,
java.util.List<java.util.List<java.lang.Integer>> discovered) |
protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> |
getAllLocationSets(java.util.List<java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob>> locOutcomes)
Takes a list of possible location outcomes for each agent and generates all joint location outcomes
|
protected java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>> |
getAllPossibleCollisionWinnerAssignment(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> collissionSets) |
protected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> |
getColissionSets(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> candidatePositions)
Returns with whom each agent is in a collision competition for a cell.
|
protected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 |
getLocation(OOState s,
java.lang.String agentName)
Returns the x-y position of an agent stored in a Location2 object.
|
protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> |
getPossibleCollisionOutcomes(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions) |
protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob> |
getPossibleLocationsFromWallCollisions(OOState s,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> agentNoOpLocs)
Returns the list of possible outcome locations for a given start point and desired position change.
|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
getWinningAgentMovements(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> collissionSets)
Takes as input the set of collisions and randomly selects a winner
|
protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> |
resolveCollisions(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions)
Resolves collisions that occur when two or more agents try to enter the same cell, in which case only one
agent will make it into the position and the rest will stay in place
|
protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> |
resolvePositionSwaps(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions)
Returns the position of each agent after accounting for collisions that are a result of agents
trying to move into each others previous locations.
|
State |
sample(State s,
JointAction ja)
Samples the result of performing
JointAction ja in State s. |
protected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 |
sampleBasicMovement(OOState s,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta,
java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> agentNoOpLocs)
Returns a movement result of the agent.
|
protected boolean |
sampleWallCollision(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta,
java.util.List<ObjectInstance> walls,
boolean vertical)
Return true if the agent is able to move in the desired location; false if the agent moves into a solid wall
or if the agent randomly fails to move through a semi-wall that is in the way.
|
java.util.List<StateTransitionProb> |
stateTransitions(State s,
JointAction ja)
Returns the transition probabilities for applying the provided
JointAction action in the given state. |
protected int |
wallCollision(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0,
burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta,
java.util.List<ObjectInstance> walls,
boolean vertical)
Indicates whether there are any wall collisions.
|
public GridGameStandardMechanics(Domain d)
d
- the domain objectpublic GridGameStandardMechanics(Domain d, double semiWallPassThroughProb)
d
- d the domain objectsemiWallPassThroughProb
- the probability that an agent will pass through a semi-wall.public java.util.List<StateTransitionProb> stateTransitions(State s, JointAction ja)
FullJointModel
JointAction
action in the given state.
Transition probabilities are specified as list of StateTransitionProb
objects. The list
is only required to contain transitions with non-zero probability.stateTransitions
in interface FullJointModel
s
- the state in which the joint action is performedja
- the joint action performedStateTransitionProb
objects.public State sample(State s, JointAction ja)
JointModel
JointAction
ja in State
s.sample
in interface JointModel
s
- the state in which the joint action is performed.ja
- the joint action to be performedprotected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 getLocation(OOState s, java.lang.String agentName)
s
- the state in which the agent existsagentName
- the name of the agent.GridGameStandardMechanics.Location2
object containing the agents position in the world.protected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 attemptedDelta(java.lang.String actionName)
actionName
- the action taken.protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> resolvePositionSwaps(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions)
originalPositions
- the original position of the agents before their actions were taken.desiredPositions
- the new position the agents are trying to go intoprotected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> resolveCollisions(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions)
originalPositions
- the positions of the agents in the original state before their actions were takendesiredPositions
- the desired locations of the agentsprotected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> getPossibleCollisionOutcomes(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> originalPositions, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> desiredPositions)
protected java.util.Map<java.lang.Integer,java.lang.Integer> getWinningAgentMovements(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> collissionSets)
collissionSets
- the set of collisions; maps from one agent index to a list of the agents with whom he is competing for a cellprotected java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> getColissionSets(java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> candidatePositions)
candidatePositions
- a list of the positions to which each agent would like to go; the Location2 in index 1 indicates the location the 1th index agent
wants to go to.protected burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 sampleBasicMovement(OOState s, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> agentNoOpLocs)
s
- the state containing the agentp0
- the initial position of the agentdelta
- the desired change of position.agentNoOpLocs
- the locations occupied by agents who are not moving.protected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob> getPossibleLocationsFromWallCollisions(OOState s, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2> agentNoOpLocs)
s
- the state in which the changes would occurp0
- the initial locationdelta
- the desired change in positionagentNoOpLocs
- the locations occupied by agents who are not movingprotected boolean sampleWallCollision(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta, java.util.List<ObjectInstance> walls, boolean vertical)
p0
- the initial location of the agentdelta
- the desired change in direction of the agentwalls
- the list of walls in the worldvertical
- whether the list of provided walls are vertical or horizontal wallsprotected int wallCollision(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta, java.util.List<ObjectInstance> walls, boolean vertical)
p0
- the original locationdelta
- the desired change in directionwalls
- possible wall objectsvertical
- true if the wall objects are vertical; false if they are horizontalprotected boolean crossesWall(burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 p0, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2 delta, ObjectInstance w, boolean vertical)
p0
- the initial state of the agentdelta
- the desired change in directionw
- wall instance to checkvertical
- true if the wall is a vertical wall; false if the wall is a horizontal wallprotected java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> getAllLocationSets(java.util.List<java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob>> locOutcomes)
locOutcomes
- a list of possible location outcomesprotected void generateAllLocationSetsHelper(java.util.List<java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2Prob>> locOutcomes, int i, burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.Location2[] locArray, double stackedProb, java.util.List<burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics.LocationSetProb> discovered)
locOutcomes
- the list of possible location outcomes for each agenti
- the index from which to generate possible outcomes in a depth-first mannerlocArray
- an array holding the current assignments for a given depthstackedProb
- the probability of this location set occurringdiscovered
- the discovered combinations thus farprotected java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>> getAllPossibleCollisionWinnerAssignment(java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> collissionSets)
protected void generateAllPossibleCollisionWinnerAssignments(java.util.List<java.util.List<java.lang.Integer>> collisionLists, int i, int[] assignment, java.util.List<java.util.List<java.lang.Integer>> discovered)
protected java.util.List<StateTransitionProb> combineDuplicateTransitionProbabilities(java.util.List<StateTransitionProb> srcTPs)
srcTPs
- and initial list of transition probability objectsprotected boolean agentsEqual(OOState s1, OOState s2)
s1
- the first states2
- the second stateprotected java.lang.String agentName(int agentNum, OOState s)