eishub / eis

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.
GNU General Public License v3.0
9 stars 4 forks source link

eis.EIDefaultImpl.deleteEntity(String) superflous exceptions #3

Open Wouter1 opened 10 years ago

Wouter1 commented 10 years ago

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;