Skip to content

Commit

Permalink
Add hc-0.5 rating option for all rating computations
Browse files Browse the repository at this point in the history
Relates to #7
  • Loading branch information
anoek committed Jan 15, 2021
1 parent 3c9b0d1 commit 50b5443
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions analysis/util/RatingMath.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
D = 0
P = 1
HALF_STONE_HANDICAP = False
HALF_STONE_HANDICAP_FOR_ALL_RANKS = False

cli.add_argument(
"--half-stone-handicap", dest="half_stone_handicap", const=1, default=False, action="store_const", help="Use a 0.5 rank adjustment for hc1",
)
cli.add_argument(
"--half-stone-handicap-for-all-ranks", dest="half_stone_handicap_for_all_ranks", const=1, default=False, action="store_const", help="use rankdiff -0.5 for handicap",
)

logarithmic = cli.add_argument_group(
"logarithmic ranking variables", "rating to ranks converted with `(log(rating / a) ** p) * c + d`",
Expand Down Expand Up @@ -73,6 +77,9 @@ def set_exhaustive_log_parameters(a: float, c:float, d:float, p:float = 1.0) ->

def get_handicap_adjustment(rating: float, handicap: int) -> float:
global HALF_STONE_HANDICAP
global HALF_STONE_HANDICAP_FOR_ALL_RANKS
if HALF_STONE_HANDICAP_FOR_ALL_RANKS:
return rank_to_rating(rating_to_rank(rating) + (handicap - 0.5 if handicap > 0 else 0)) - rating
if HALF_STONE_HANDICAP:
return rank_to_rating(rating_to_rank(rating) + (0.5 if handicap == 1 else handicap)) - rating
return rank_to_rating(rating_to_rank(rating) + handicap) - rating
Expand All @@ -89,8 +96,10 @@ def configure_rating_to_rank(args: argparse.Namespace) -> None:
global C
global D
global HALF_STONE_HANDICAP
global HALF_STONE_HANDICAP_FOR_ALL_RANKS

HALF_STONE_HANDICAP = args.half_stone_handicap
HALF_STONE_HANDICAP_FOR_ALL_RANKS = args.half_stone_handicap_for_all_ranks
system: str = args.ranks
a: float = args.a
c: float = args.c
Expand Down

0 comments on commit 50b5443

Please sign in to comment.