public class LearningAgentToSGAgentInterface extends SGAgent implements Environment
SGAgent
that takes as input a single agent LearningAgent
to handle behavior. The interface from the single agent paradigm to the multi-agent paradigm is handled by this class
also implementing the Environment
interface. When a game starts, a new
thread is launched in which the provided LearningAgent
interacts with this
class's Environment
methods.
LearningAgent
to use with this class, you should
set its Domain
to null. Then, when this class joins a world through the joinWorld(burlap.oomdp.stochasticgames.World, burlap.oomdp.stochasticgames.SGAgentType)
method, it will automatically use the SGToSADomain
to create a SADomain
and will then set then LearningAgent
to use it.Modifier and Type | Class and Description |
---|---|
protected static class |
LearningAgentToSGAgentInterface.ActionReference
A wrapper that maintains a reference to a
GroundedSGAgentAction or null. |
protected static class |
LearningAgentToSGAgentInterface.StateReference
A wrapper that maintains a reference to a
State or null. |
Modifier and Type | Field and Description |
---|---|
protected State |
currentState
The current state of the world
|
protected boolean |
curStateIsTerminal
Whether the last state was a terminal state
|
protected double |
lastReward
The last reward received by this agent
|
protected LearningAgent |
learningAgent
The single agent
LearningAgent that will be learning
in this stochastic game as if the other players are part of the environment. |
protected LearningAgentToSGAgentInterface.ActionReference |
nextAction
The next action selected by the single agent
|
protected LearningAgentToSGAgentInterface.StateReference |
nextState
The next state received
|
protected java.lang.Thread |
saThread
The thread that runs the single agent learning algorithm
|
agentType, domain, internalRewardFunction, world, worldAgentName
Constructor and Description |
---|
LearningAgentToSGAgentInterface(SGDomain domain,
LearningAgent learningAgent)
Initializes.
|
Modifier and Type | Method and Description |
---|---|
EnvironmentOutcome |
executeAction(GroundedAction ga)
Executes the specified action in this environment
|
void |
gameStarting()
This method is called by the world when a new game is starting.
|
void |
gameTerminated()
This method is called by the world when a game has ended.
|
GroundedSGAgentAction |
getAction(State s)
This method is called by the world when it needs the agent to choose an action
|
State |
getCurrentObservation()
Returns the current observation of the environment as a
State . |
double |
getLastReward()
Returns the last reward returned by the environment
|
boolean |
isInTerminalState()
Returns whether the environment is in a terminal state that prevents further action by the agent.
|
void |
joinWorld(World w,
SGAgentType as)
Causes this agent instance to join a world.
|
void |
observeOutcome(State s,
JointAction jointAction,
java.util.Map<java.lang.String,java.lang.Double> jointReward,
State sprime,
boolean isTerminal)
This method is called by the world when every agent in the world has taken their action.
|
void |
resetEnvironment()
Resets this environment to some initial state, if the functionality exists.
|
getAgentName, getAgentType, getInternalRewardFunction, init, setInternalRewardFunction
protected LearningAgent learningAgent
LearningAgent
that will be learning
in this stochastic game as if the other players are part of the environment.protected boolean curStateIsTerminal
protected double lastReward
protected State currentState
protected java.lang.Thread saThread
protected LearningAgentToSGAgentInterface.ActionReference nextAction
protected LearningAgentToSGAgentInterface.StateReference nextState
public LearningAgentToSGAgentInterface(SGDomain domain, LearningAgent learningAgent)
domain
- The stochastic games SGDomain
in which this agent will interact.learningAgent
- the LearningAgent
that will handle this SGAgent
's control.public void joinWorld(World w, SGAgentType as)
SGAgent
public void gameStarting()
SGAgent
gameStarting
in class SGAgent
public GroundedSGAgentAction getAction(State s)
SGAgent
public void observeOutcome(State s, JointAction jointAction, java.util.Map<java.lang.String,java.lang.Double> jointReward, State sprime, boolean isTerminal)
SGAgent
observeOutcome
in class SGAgent
s
- the state in which the last action of each agent was takenjointAction
- the joint action of all agents in the worldjointReward
- the joint reward of all agents in the worldsprime
- the next state to which the agent transitionedisTerminal
- whether the new state is a terminal statepublic void gameTerminated()
SGAgent
gameTerminated
in class SGAgent
public State getCurrentObservation()
Environment
State
.getCurrentObservation
in interface Environment
State
.public EnvironmentOutcome executeAction(GroundedAction ga)
Environment
executeAction
in interface Environment
ga
- the GroundedAction that is to be performed in this environment.public double getLastReward()
Environment
getLastReward
in interface Environment
public boolean isInTerminalState()
Environment
isInTerminalState
in interface Environment
public void resetEnvironment()
Environment
resetEnvironment
in interface Environment