Skip to content

Commit 00d707a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 32d9b88 commit 00d707a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

maths/elo_expected_score.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22

3+
34
def calculate_elo_expected_score(rating_a: int, rating_b: int) -> float:
45
"""
56
Calculate the expected score (probability of winning) for Player A against Player B using Elo ratings.
@@ -17,6 +18,7 @@ def calculate_elo_expected_score(rating_a: int, rating_b: int) -> float:
1718
exponent = (rating_b - rating_a) / 400
1819
return 1.0 / (1.0 + math.pow(10, exponent))
1920

21+
2022
def test_calculate_elo_expected_score():
2123
# Player A higher rating
2224
assert 0.5 < calculate_elo_expected_score(1600, 1400) < 1.0
@@ -25,10 +27,11 @@ def test_calculate_elo_expected_score():
2527
# Equal ratings
2628
assert calculate_elo_expected_score(1500, 1500) == 0.5
2729

30+
2831
if __name__ == "__main__":
2932
ra, rb = 1600, 1400
3033
expected_a = calculate_elo_expected_score(ra, rb)
3134
print(f"Player A Rating: {ra}")
3235
print(f"Player B Rating: {rb}")
3336
print(f"Expected Score for Player A: {expected_a:.4f}")
34-
print(f"Expected Score for Player B: {1.0 - expected_a:.4f}")
37+
print(f"Expected Score for Player B: {1.0 - expected_a:.4f}")

0 commit comments

Comments
 (0)