Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

[READY] adds strategy viz cli #160

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

Conversation

big-c-note
Copy link
Collaborator

@big-c-note big-c-note commented Apr 2, 2023

@fedden
Added a vizualization to the cli. It is an extension of what you started building years ago. Get started with poker_ai viz

Here's an example:

strat_dag_viz_.mov

This shows a visualization of the bot's strategy starting with at flop. Colors are showing states the bot visited.

Importantly I had to add data for the current betting stage to the strategy to make this happen. I was careful to make sure it affected no other modules, and all tests pass. I also trained a new bot and played it in the terminal with these changes.

Information

"""
  Create a vizualization of a bot's strategy in your browser. You can get
  started with the provided test data without any flags.
  >>> poker_ai viz
  Prerequisites
  -------------
  - You must have a strategy trained via the `poker_ai cluster` and `poker_ai
  train` commands in addition to the repo's installation instructions. Though,
  there is test data included for the `poker_ai viz` command when the
  `strategy_dir` is None.
  - You'll need to get an infoset to vizualize, you can copy one from the
  output of the strategy.
  >>> strategy = joblib.load('path/to/strategy_dir/agent.joblib')
  >>> strategy['strategy'].keys()
  Make sure to user '' around the infoset so it can be parsed by your shell.
  Example.

'{"cards_cluster":9,"betting_stage":"turn","history":[{"pre_flop":["raise",
"raise","raise","call","call"]},{"flop":["raise","raise","fold","call"]},{
"turn":["raise","raise"]}]}'

For details on the accepted arguments and defaults.
>>> poker_ai viz --help
Options:
--strategy_dir PATH  Path to the strategy directory.
--info_set_str TEXT  Infoset to vizualize, you can copy one from the output
                     of the strategy.
                     >>> strategy =
                     joblib.load('path/to/strategy_dir/agent.joblib')
                     >>> strategy['strategy'].keys()
                     Make sure to user '' around the infoset so it can be
                     parsed by your shell.
                     Eg; '{"cards_cluster":1,"betting_stage":"flop","history
                     ":[{"pre_flop":["call", "call","call"]}]}'
--max_depth INTEGER  Max depth of the viz.  Recommend 7 or less, as the tree
                     grows exponentially (~^3)
--host TEXT          The interface to bind to.
--port INTEGER       The port to bind to.
--help               Show this message and exit.
"""

@big-c-note big-c-note requested a review from fedden April 2, 2023 23:12
@CLAassistant
Copy link

CLAassistant commented Apr 2, 2023

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ bigcnote
❌ big-c-note


bigcnote seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

2 participants