public class EnvironmentServer extends java.lang.Object implements EnvironmentServerInterface, EnvironmentDelegation
EnvironmentServerInterface
implementation that delegates all Environment
interactions and request
to a provided Environment
delegate. This class will also
intercept all interactions through the executeAction(Action)
and
resetEnvironment()
methods
and tell all EnvironmentOutcome
instances registered with this server
about the event.Modifier and Type | Class and Description |
---|---|
static class |
EnvironmentServer.StateSettableEnvironmentServer |
EnvironmentDelegation.Helper
Modifier and Type | Field and Description |
---|---|
protected Environment |
delegate
the
Environment delegate that handles all primary Environment
functionality. |
protected java.util.List<EnvironmentObserver> |
observers
The
EnvironmentObserver objects that will be notified of Environment
events. |
Constructor and Description |
---|
EnvironmentServer(Environment delegate,
EnvironmentObserver... observers) |
Modifier and Type | Method and Description |
---|---|
void |
addObservers(EnvironmentObserver... observers)
Adds one or more
EnvironmentObserver s |
void |
clearAllObservers()
Clears all
EnvironmentObserver s from this server. |
static EnvironmentServer |
constructor(Environment delegate,
EnvironmentObserver... observers)
Constructs an
EnvironmentServer or EnvironmentServer.StateSettableEnvironmentServer ,
based on whether the input delegate implements StateSettableEnvironment . |
static EnvironmentServerInterface |
constructServerOrAddObservers(Environment env,
EnvironmentObserver... observers)
If the input
Environment is an instance EnvironmentServerInterface ,
then all the input observers are added to it and it is returned. |
State |
currentObservation()
Returns the current observation of the environment as a
State . |
EnvironmentOutcome |
executeAction(Action ga)
Executes the specified action in this environment
|
Environment |
getEnvironmentDelegate()
Returns the
Environment delegate that handles all Environment
functionality |
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
|
java.util.List<EnvironmentObserver> |
observers()
Returns all
EnvironmentObserver s registered with this server. |
void |
removeObservers(EnvironmentObserver... observers)
Removes one or more
EnvironmentObserver s from this server. |
void |
resetEnvironment()
Resets this environment to some initial state, if the functionality exists.
|
void |
setEnvironmentDelegate(Environment delegate)
Sets the
Environment delegate that handles all Environment functionality |
protected Environment delegate
Environment
delegate that handles all primary Environment
functionality.protected java.util.List<EnvironmentObserver> observers
EnvironmentObserver
objects that will be notified of Environment
events.public EnvironmentServer(Environment delegate, EnvironmentObserver... observers)
public static EnvironmentServerInterface constructServerOrAddObservers(Environment env, EnvironmentObserver... observers)
Environment
is an instance EnvironmentServerInterface
,
then all the input observers are added to it and it is returned. Otherwise, a new EnvironmentServer
is created around it, with all of the observers added.env
- the Environment
that will have observers added to itobservers
- the EnvironmentObserver
objects to add.Environment
or an EnvironmentServer
.public static EnvironmentServer constructor(Environment delegate, EnvironmentObserver... observers)
EnvironmentServer
or EnvironmentServer.StateSettableEnvironmentServer
,
based on whether the input delegate implements StateSettableEnvironment
.delegate
- the delegate Environment
for most environment interactions.observers
- the EnvironmentObserver
objects notified of Environment events.EnvironmentServer
or EnvironmentServer.StateSettableEnvironmentServer
.public Environment getEnvironmentDelegate()
Environment
delegate that handles all Environment
functionalitygetEnvironmentDelegate
in interface EnvironmentDelegation
Environment
delegatepublic void setEnvironmentDelegate(Environment delegate)
Environment
delegate that handles all Environment
functionalitysetEnvironmentDelegate
in interface EnvironmentDelegation
delegate
- the Environment
delegatepublic void addObservers(EnvironmentObserver... observers)
EnvironmentObserver
saddObservers
in interface EnvironmentServerInterface
observers
- and EnvironmentObserver
public void clearAllObservers()
EnvironmentObserver
s from this server.clearAllObservers
in interface EnvironmentServerInterface
public void removeObservers(EnvironmentObserver... observers)
EnvironmentObserver
s from this server.removeObservers
in interface EnvironmentServerInterface
observers
- the EnvironmentObserver
s to remove.public java.util.List<EnvironmentObserver> observers()
EnvironmentObserver
s registered with this server.observers
in interface EnvironmentServerInterface
EnvironmentObserver
s registered with this server.public State currentObservation()
Environment
State
.currentObservation
in interface Environment
State
.public EnvironmentOutcome executeAction(Action ga)
Environment
executeAction
in interface Environment
ga
- the Action that is to be performed in this environment.public double lastReward()
Environment
lastReward
in interface Environment
public boolean isInTerminalState()
Environment
isInTerminalState
in interface Environment
public void resetEnvironment()
Environment
resetEnvironment
in interface Environment