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

freePair() results in internal inconsistency in AbstractEnvironment #42

Open Wouter1 opened 10 years ago

Wouter1 commented 10 years ago

AbstractEnvironment extends EIDefaultImpl.

Therefore it inherits the freePair(agent,entity) function

freePair removes its references to the entity (from LinkedList? entities and ConcurrentHashMap<String, HashSet> agentsToEntities)

(BTW interesting but useless attempt here at making EIDefaultImpl thread safe by using ConcurrentHashMap??)

However AbstractEnvironment maintains its own copy of the existing entities: Map<String, Object> entities.

Because AbstractEnvironment never updates its copy when freePair is called, this results in an inconsistent state in AbstractEnvironment. For example, AbstractEnvironment#getEntity will still return the non-removed entity.

Wouter1 commented 10 years ago

We discussed this, the proposal is to not keep shadow copies. If the hashmap is preferable (eg for performance reasons?), fix EIDefaultImpl and do not make shadow copies.

Wouter1 commented 10 years ago

Added @Override to EIDefaultImpl functions that actually override, to clarify what is really implementation of EnvironmentInterfaceStandard.

It's not so easy to fix this in a clean way, I considered copying the code but EIDefaultImp is too large (1255 lines). See also http://ii.tudelft.nl/trac/goal/ticket/3341