Adding Pre-trained/Rule-based models
February 20, 2020 ยท View on GitHub
You can add your own pre-trained/rule-based models to the toolkit by following several steps:
- Develop models. You can either design a rule-based model or save a neural network model. For each game, you need to develop agents for all the players at the same time. You need to wrap each agent as a
Agentclass and make sure thatstep,eval_stepanduse_rawcan work correctly. - Wrap models. You need to inherit the
Modelclass inrlcard/models/model.py. Then put all the agents into a list. Rewriteagentproperty to return this list. - Register the model. Register the model in
rlcard/models/__init__.py. - Load the model in environment. An example of loading
leduc-holdem-nfspmodel is as follows:
from rlcard import models
leduc_nfsp_model = models.load('leduc-holdem-nfsp')
Then use leduc_nfsp_model.agents to obtain all the agents for the game.