Adding New Environments
July 11, 2021 ยท View on GitHub
To add a new environment to the toolkit, generally you should take the following steps:
- Implement a game. Card games usually have similar structures so that they can be implemented with
Game,Round,Dealer,Judger,Player, as in existing games. The easiest way is to inherit the classed in rlcard/games/base.py and implement the functions. - Wrap the game with an environment. The easiest way is to inherit
Envin rlcard/envs/env.py. You need to implement_extract_statewhich encodes the state,_decode_actionwhich decodes actions from the id to the text string, andget_payoffswhich calculates payoffs of the players. - Register the game. Now it is time to tell the toolkit where to locate the new environment. Go to rlcard/envs/__init__.py, and indicate the name of the game and its entry point.
To test whether the new environment is set up successfully:
import rlcard
rlcard.make(#the new evironment#)