Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Specify opponent by path #337

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

sakami0000
Copy link

@sakami0000 sakami0000 commented Dec 13, 2022

  • Agent specification at evaluation can be done by path.

src/agent.py

from handyrl.agent import RandomAgent
from handyrl.evaluation import register_agent


@register_agent(alias="transformer")
class TransformerAgent(RandomAgent):
    def __init__(self, temperature=0.0):
        self.temperature = temperature

    def action(self, env, player, show=False):
        action = model_predict(env, player, temperature=self.temperature)
        return action
python main.py -e random:src.agent.TransformerAgent 100 8
  • Arguments can be set by comma-separated style.
python main.py -e random:src.agent.TransformerAgent,temperature=1.0 100 8
  • Strings containing comma are given as arguments by enclosing them in quotation marks.

NOTE: The entire target value must be enclosed in another quotation marks because quotation marks are erased in python arguments.

python main.py -e random:'src.agent.TransformerAgent,hoge="hoge, fuga"' 100 8
  • Alias can be set by using handyrl.evaluation.register_agent.

NOTE: The agent class must be defined in the current context.

main.py

import src.agent
python main.py -e random:transformer,temperature=0.5 100 8
  • All of the above features can also be used in opponent specifications in config.yaml.
opponent: [
    'src.agent.TransformerAgent,temperature=0.5',
    'src.agent.TransformerAgent,temperature=0.5,hoge="hoge, fuga"'
]
  • Spaces before and after commas are automatically erased.
opponent: [
    'src.agent.TransformerAgent, temperature=0.5',
    'src.agent.TransformerAgent, temperature=0.5, hoge="hoge, fuga"'
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant