ENH: Create tests for MixedBehaviorProfile as_strategy
This issue is about MixedBehaviorProfile.as_strategy, which turns a behavior profile into a MixedStrategyProfile.
There are currently no tests for as_strategy (an old test for this was removed because it was not particularly useful and was even misleading).
New tests should be written for as_strategy. Two that certainly make sense are:
- A consistency test that checks that the expected payoff of the original behavior profile matches the expected payoff computed for the mixed strategy that is return by
as_strategy. - A reference test that uses manual calculations which implement Kuhn's theorem to convert a behavior strategy to a mixed strategy.
A fortiori we might consider renaming that to as_mixed_strategy_profile or to_mixed_strategy_profile to be more consistent with nomenclature elsewhere.
Hi @tturocy @rahulsavani ,I’m interested in contributing to this issue if it’s still available. I’ve read through the description and understand that the task involves adding consistency and reference tests for MixedBehaviorProfile.as_strategy. Please let me know if I may proceed with working on this.
Hi! I'd like to work on this issue. I went through the existing as_strategy() implementation and the tests in tests/test_behav.py. I was thinking of adding a couple of focused tests: one to verify payoff consistency after converting to a mixed strategy, and another using a small non-uniform behavior profile to check the expected pure-strategy probabilities. I plan to keep the changes limited to tests/test_behav.py and follow the existing pytest style. Is this approach fine? I'd be happy to adjust the tests based on your suggestions before opening a PR.
Hi! I'd like to work on this issue. I went through the existing as_strategy() implementation and the tests in tests/test_behav.py. I was thinking of adding a couple of focused tests: one to verify payoff consistency after converting to a mixed strategy, and another using a small non-uniform behavior profile to check the expected pure-strategy probabilities. I plan to keep the changes limited to tests/test_behav.py and follow the existing pytest style. Is this approach fine? I'd be happy to adjust the tests based on your suggestions before opening a PR.
Thank you for your interest. However this issue does require at least an intermediate understanding of game theory to be able to do something useful.
I went back over this. I used stripped-down poker so Alice actually has two infosets. I set King to a 3/4 bet and Queen to a 1/3 bet. Bob calls 2/3 of the time, though that doesn’t really matter for her conversion.
So the mixed probabilities are just the products: bet/bet = 3/4 * 1/3 = 1/4 bet/fold = 3/4 * 2/3 = 1/2 fold/bet = 1/4 * 1/3 = 1/12 fold/fold = 1/4 * 2/3 = 1/6
They add up to 1, which was the check I used to make sure I hadn’t dropped a plan. For the tests, I was thinking of doing the payoff check (behavior vs as_strategy) and then hardcoding those four numbers rather than doing the multiplication in the test. I can do both the rational and float versions.
If that’s the idea you wanted, I can put up a PR
Hey @tturocy @rahulsavani , can I pick up this issue and give it a try?
I have taken a course on Game Theory and learning Gambit's implementations on the side. I have been reading the documentation, the new v17 one as well as the prev one. I am genuinely interested and would like to help do something impactful here.
Are there any community channels or meetings that happen periodically, or else, what are some good first steps along with a good first issue? (I did put an email to the gambit account)