-
Notifications
You must be signed in to change notification settings - Fork 282
Bayesian forgiver strategy #1478
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
Conversation
|
Thanks for this. The CI is failing because line 140 of this file is not hit by a test. |
…all cooperation rate is high enough
|
Thanks @drvinceknight - added the necessary test and also ran the required black formatter. |
| @@ -1,12 +1,12 @@ | |||
| $\\phi$: | |||
| $\phi$: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand what is happening with this file @hodgesmr ? Was this done by running https://github.com/Axelrod-Python/Axelrod/blob/dev/axelrod/classifier.py#L91 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is from the commit: c2619eb
I was following the documentation for adding a new strategy: "To classify the new strategy, run rebuild_classifier_table: python rebuild_classifier_table.py"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Cool.
|
I've decided to close this PR, especially as #1479 is being considered by the maintainers. I want to make sure contributions are accurate and productive, and I don't want this to distract or interfere with that. Thank you @drvinceknight and the other maintainers for the thoughtful time spent on this. |
Note: This strategy was ideated and developed with the assistance of Claude Code. I did not see an LLM policy in the repository, but I felt it was important to note that, given open source sensitivities to those tools. I did manual review, edits, and iterations on the implementation and testing.
Summary
This PR introduces BayesianForgiver, a strategy that uses Bayesian inference to model opponent behavior and make adaptive forgiveness decisions based on uncertainty.
Motivation
While the Axelrod library contains many strategies, none use Bayesian opponent modeling to inform decision-making. Existing forgiveness strategies use fixed thresholds or probabilities, regardless of confidence in their assessment of the opponent.
BayesianForgiver introduces uncertainty-aware decision making to the IPD strategy landscape.
Key Features
BayesianForgiver maintains a Beta distribution representing beliefs about the opponent's cooperation probability. It uses both the mean (expected cooperation rate) and variance (uncertainty) to make decisions:
This approach provides noise resilience and adaptive behavior compared to fixed-threshold strategies.
Algorithm
Implementation Details
prior_alpha=1.0
prior_beta=1.0
base_forgiveness_threshold=0.45 # Base component of forgiveness threshold
uncertainty_factor=2.5 # Increases caution under uncertainty (raises threshold early)
Tests cover: