This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
def calc_confidence_3way(top_prob: float) -> float:
|
||||
"""Returns the true win probability percentage (e.g. 0.45 -> 45.0)."""
|
||||
return max(0, min(99.0, top_prob * 100))
|
||||
|
||||
def calc_confidence_2way(prob: float) -> float:
|
||||
"""Returns the true win probability percentage for the favored side."""
|
||||
# Find the probability of the >0.5 side
|
||||
win_prob = prob if prob >= 0.5 else (1.0 - prob)
|
||||
return max(0, min(99.0, win_prob * 100))
|
||||
|
||||
def calc_confidence_dc(top_prob: float) -> float:
|
||||
"""Returns the true win probability percentage for double chance."""
|
||||
return max(0, min(99.0, top_prob * 100))
|
||||
|
||||
def calc_confidence_3way_with_agreement(top_prob: float, agreement_ratio: float,
|
||||
boost: float = 1.05, penalty: float = 0.95) -> float:
|
||||
"""
|
||||
Returns the true win probability percentage, slightly adjusted by engine consensus.
|
||||
|
||||
Args:
|
||||
top_prob: highest probability among options
|
||||
agreement_ratio: 0.0 to 1.0 — how many engines agree on the pick
|
||||
"""
|
||||
base = calc_confidence_3way(top_prob)
|
||||
|
||||
# Slight nudge rather than massive swing, to keep it feeling like a true probability
|
||||
if agreement_ratio >= 0.75:
|
||||
return min(99.0, base * boost)
|
||||
elif agreement_ratio <= 0.25:
|
||||
return max(0.0, base * penalty)
|
||||
|
||||
return base
|
||||
Reference in New Issue
Block a user