The observation of agents in Pommerman is not the same as the game state. Not only can the items (such as Extra Bomb item) not be seen, but agents cannot know the number of ammo others have with only the current observation. However, we can simulate most of them by preceding observations, which the SimAgent in this repo does.
However, there are some inevitable limitations which are explained here, which SimAgent has tried to diminish.
git clone --recurse-submodules git@github.com:guikarist/sim-agent.git
cd sim-agent
conda env create -f pommerman/env.yml
conda activate pommerman
To use the Sim Agent, all you need to do is:
- Subclass the
SimAgentclass insim_agent.py. - Implement the
_act(self, obs, action_space)method. Or after investigating the logics, you can overrideact(self, obs, action_space)for advanced usages.
The simulated information of SimAgent is:
-
List[_Item] self._itemsA list of items which are observable on the board. The information of
_Item()is:_Pos self.posThe position of an item_ItemType self.typeThe type of an item
-
List[_Bomb] self._bombsA list of bombs which are observable on the board. The information of
_Bomb()is:_Pos self.posThe position of a bomb_Agent self.bomberThe bomber of a bombBlastStrengthType self.blast_strengthThe blast strength of a bombActionType self.first_moving_directionThe first moving direction of a bombbool self.has_been_movedThe moving state of a bomb (Trueonce the bomb has been moved before)BombLifeType self.lifeThe life of a bomb (This may be INACCURATE when the bombhas_been_moved)
-
List[_Agent] self._agentsA list of alive agents in the game. The information of
_Agent()is:_Pos self.pos: The agent positionAgentIdType self.idThe agent id (e.g.,0)AgentValueType self.valueThe agent value (e.g.,10)AmmoType self.ammoThe number of ammo of an agent (This may be INACCURATE)bool self.can_kick: The ability to kick bombs of an agent (This may be INACCURATE)BlastStrengthType self.blast_strength: The blast strength of an anget (This may be INACCURATE)
For the correctness of the simulation, tests are necessary.
This will test add_ability() of _Agent, games of one SimAgent with three RandomAgent, and games of one SimAgent with three SimpleAgent.
python test_sim_agent.py
This will initialize games with one PlayerAgent, one SimAgent and two _IdleAgent (which does nothing but stop), where you can test manually by playing.
python test_sim_agent.py TestSimAgent._test_simulation_by_player_agent
The simulation is impossible to be perfect and here is an example:
It is possible for an agent to get an item while no others see: if at some step, these three things happen at the same time: a box is destroyed by flame of bombs, an agent move to the position of this box and there is an item below this box.
Thus, when this kind of situations happen, these information of agent simulation cannot be accurate:
- ammo
- blast strength
- the ability to kick a bomb