Skip to content

Commit 3a4e569

Browse files
committed
comment and docstring cleanup
1 parent 097d501 commit 3a4e569

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

axelrod/strategies/bayesian_forgiver.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class BayesianForgiver(Player):
2121
opponent's cooperation probability. It uses both the mean (expected cooperation
2222
rate) and variance (uncertainty) to make decisions:
2323
24-
- When uncertain about the opponent's nature, it is optimistic and forgives more
24+
- When uncertain about the opponent's nature, it is cautious
2525
- When certain the opponent is hostile, it punishes consistently
2626
- When certain the opponent is cooperative, it cooperates consistently
2727
@@ -32,7 +32,7 @@ class BayesianForgiver(Player):
3232
4. Calculate mean = alpha / (alpha + beta)
3333
5. Calculate uncertainty (std deviation)
3434
6. Adaptive forgiveness: threshold = base_threshold + uncertainty_factor * uncertainty
35-
7. Forgive if mean > threshold, otherwise punish
35+
7. Forgive a defection only if the estimated cooperation rate clears this threshold
3636
3737
Names:
3838
- Bayesian Forgiver: Original name by Matt Hodges
@@ -72,8 +72,7 @@ def __init__(
7272
Base threshold for forgiveness decision (default: 0.45)
7373
If estimated cooperation probability > threshold, forgive defections
7474
uncertainty_factor : float
75-
How much uncertainty increases forgiveness (default: 2.5)
76-
Higher values mean more optimism under uncertainty
75+
How much uncertainty increases the forgiveness threshold (default: 2.5)
7776
7877
Note: Default parameters have been optimized through grid search
7978
to maximize performance against common IPD strategies.
@@ -123,7 +122,6 @@ def strategy(self, opponent: Player) -> Action:
123122
uncertainty = variance**0.5
124123

125124
# Adaptive forgiveness threshold
126-
# Higher uncertainty → higher threshold → more forgiving
127125
forgiveness_threshold = (
128126
self.base_forgiveness_threshold
129127
+ self.uncertainty_factor * uncertainty
@@ -136,8 +134,7 @@ def strategy(self, opponent: Player) -> Action:
136134
else:
137135
# Opponent defected last round - decide whether to forgive or punish
138136
if mean_cooperation >= forgiveness_threshold:
139-
# Opponent's estimated cooperation rate is high enough to forgive
140-
# OR we're uncertain enough to be optimistic
137+
# Forgive only when the estimated cooperation rate is high enough.
141138
return C
142139
else:
143140
# Opponent appears to be hostile with sufficient confidence

0 commit comments

Comments
 (0)