The Environment Interface Standard (EIS) is a Java-based interface standard for connecting agents to controllable entities in an environment such as a game. The interface provides support for managing the connection (e.g., for pausing and terminating an environment) and for interaction between agents and entities that are available in an environment (e.g., bots in a game). An agent that is connected to a controllable entity receives percepts from and can send actions to that entity. Percepts inform the agent about the state of the entity and its environment. Actions tell the entity which actions to perform in its environment. Several example implementations of environments are available @github.com/eishub. A default implementation of the EIS interface is also provided.
The method eis.EIDefaultImpl.deleteEntity(String) declares two exceptions that should not be thrown.
Use case:
The Unreal Environment uses UT bots which reside on a remote server. Occasionally the connection may drop or the bot may be kicked from the server.
At this point the bot is no longer available as an entity to agents using the environment and so it needs to be deleted.
The Problem:
The section of code that throws a RelationException has been commented out but the Exception itself is still declared. There seems to be no reason for this.
The method also tests to see if the entity that is removed actually exists and throws an EntityException if it doesn't. However the deleteEntity method is protected so the only reason an entity could not exist would be its deletion by the environment that is trying to delete it. Which is bad coding rather then an Exceptional situation.
Both result in rather silly code:
/**
Synchronized version of {@link AbstractEnvironment.deleteEntity}. Used by
{@link AgentDownListener} to removed agents that have shut down.
*
@param entity
to remove.
*/
protected synchronized void synchronizedDeleteEntity(String name) {
try {
deleteEntity(name);
} catch (RelationException e) {
// TODO: This relationship exception is no longer thrown.
log.severe("Could not delete entity " + name);
} catch (EntityException e) {
// TODO: This should be replaced by an assertion in the default
// implementation of EIS.
log.severe("Could not delete entity " + name + ", it was already deleted.");
}
}
Requested solution:
Removal of RelationException and EntityException.
Replacement of
// check if exists
if( !entities.contains(entity) )
throw new EntityException("Entity \"" + entity + "\" does not exist!");
With:
// check if exists
if( !entities.contains(entity) )
return;
The method eis.EIDefaultImpl.deleteEntity(String) declares two exceptions that should not be thrown.
Use case:
The Unreal Environment uses UT bots which reside on a remote server. Occasionally the connection may drop or the bot may be kicked from the server.
At this point the bot is no longer available as an entity to agents using the environment and so it needs to be deleted.
The Problem:
The section of code that throws a RelationException has been commented out but the Exception itself is still declared. There seems to be no reason for this.
The method also tests to see if the entity that is removed actually exists and throws an EntityException if it doesn't. However the deleteEntity method is protected so the only reason an entity could not exist would be its deletion by the environment that is trying to delete it. Which is bad coding rather then an Exceptional situation.
Both result in rather silly code:
/**
Requested solution:
Removal of RelationException and EntityException.
Replacement of
// check if exists if( !entities.contains(entity) ) throw new EntityException("Entity \"" + entity + "\" does not exist!");
With: // check if exists if( !entities.contains(entity) ) return;