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

weird code EIDefaultImpl#deleteEntity #8

Open Wouter1 opened 10 years ago

Wouter1 commented 10 years ago

The code in deleteEntity is weird

the for loop with break basically searches the agent associated with the entity. Why is there not a getAgent(entity) function

And then the code removes the entity from the entities associated with the agent using ens.remove(entity). This is all fine but why does the code then call

agentsToEntities.put(agent,ens)?

This call is doing nothing as agent is already associated with the ens list.

The whole for-loop should in fact be written in 1 line:

agentsToEntities.get(getAgent(entity)).remove(entity)