public class LearningAgentToSGAgentInterface extends SGAgentBase 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.| Modifier and Type | Class and Description |
|---|---|
protected static class |
LearningAgentToSGAgentInterface.ActionReference
A wrapper that maintains a reference to a
Action 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 int |
agentNum |
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,
java.lang.String agentName,
SGAgentType agentType)
Initializes.
|
| Modifier and Type | Method and Description |
|---|---|
Action |
action(State s)
This method is called by the world when it needs the agent to choose an action
|
State |
currentObservation()
Returns the current observation of the environment as a
State. |
EnvironmentOutcome |
executeAction(Action ga)
Executes the specified action in this environment
|
void |
gameStarting(World w,
int agentNum)
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.
|
boolean |
isInTerminalState()
Returns whether the environment is in a terminal state that prevents further action by the agent.
|
double |
lastReward()
Returns the last reward returned by the environment
|
void |
observeOutcome(State s,
JointAction jointAction,
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.
|
agentName, agentType, getInternalRewardFunction, init, init, setAgentDetails, setInternalRewardFunctionprotected 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
protected int agentNum
public LearningAgentToSGAgentInterface(SGDomain domain, LearningAgent learningAgent, java.lang.String agentName, SGAgentType agentType)
domain - The stochastic games SGDomain in which this agent will interact.learningAgent - the LearningAgent that will handle this SGAgent's control.agentName - the name of the agentagentType - the SGAgentType for the agent defining its action spacepublic void gameStarting(World w, int agentNum)
SGAgentgameStarting in interface SGAgentw - the world in which the game is startingagentNum - the agent number of the agent in the worldpublic Action action(State s)
SGAgentpublic void observeOutcome(State s, JointAction jointAction, double[] jointReward, State sprime, boolean isTerminal)
SGAgentobserveOutcome in interface SGAgents - 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()
SGAgentgameTerminated in interface SGAgentpublic State currentObservation()
EnvironmentState.currentObservation in interface EnvironmentState.public EnvironmentOutcome executeAction(Action ga)
EnvironmentexecuteAction in interface Environmentga - the Action that is to be performed in this environment.public double lastReward()
EnvironmentlastReward in interface Environmentpublic boolean isInTerminalState()
EnvironmentisInTerminalState in interface Environmentpublic void resetEnvironment()
EnvironmentresetEnvironment in interface Environment