Arcade-Learning-Environment
Arcade-Learning-Environment copied to clipboard
Multiplayer player API support in ALE
A cleaned up and simplified version of #350. Fully functional, pip installable project with many environments is here, with high level PettingZoo support documented here and associated workshop paper here
Atari has some great multiplayer games. This PR starts the process of supporting these games with:
- a new clean API for handling multiplayer games that is 100% backwards compatible
- Support for 2 and 4 player Pong as an example (more games will be added once this PR is merged)
New API
The new api has the following methods in addition to all the old ones (in both the python and c++ interfaces):
- numPlayersActive() -> int
- the number of players in the current mode
- act(list of actions) -> list of rewards
- overloads act(int) ->int, which is still there
- Requires that the number of actions matches numPlayersActive()
- allLives() -> list of lives
- getAvailableModes(num_players=1) -> list of modes
- returns modes that support the specified number of players.
- List is empty when the number of players is not supported at all
Note that Pong is renumbered to have the numbering scheme proposed in #397.
Notable internal changes
- Addition of functions to the RomSettings class to provide methods of getting rewards and lives for multiple players
- Addition of 2 and 4 player RomSettings classes to enforce that games override the multiplayer settings methods
- To support 4 player games like pong (included) and warlords (implemented in main project) paddles are manipulated individually by index in
ale_state.cpp, and support for manipulating all 4 paddles is included. - ALEState includes the number of players as part of the game state, StellaEnvironment sets the number of players when the game mode is changed.
- PLAYER_B actions (numbered 18-35) are not accepted to the external interface, or any function which accepts a list of actions, but are accepted in certain internal functions such as
StellaEnvironment::act(Action, Action)for backwards compatibility.