Skip to content

Commit

Permalink
final refactor of variables and assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHall2020 committed Feb 21, 2024
1 parent 560d6b0 commit a39d11e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions archeryutils/handicaps/handicap_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,25 @@ def get_max_score_handicap(

# Set rounding limit
if hc_sys in ("AA", "AA2", "AGBold"):
round_lim = 0.5
target = max_score - 0.5
else:
round_lim = 1.0
target = max_score - 1.0

def check_score(handicap):
return hc_eq.score_for_round(
rnd, handicap, hc_sys, hc_dat, arw_d, round_score_up=False
)

# Work down (coarse) to where we would round or ceil to max score
while check_score(handicap) > max_score - round_lim:
while check_score(handicap) > target:
handicap += delta_hc

# Step back extra after overshoot
handicap = handicap - (1.1 * delta_hc)
handicap -= 1.1 * delta_hc
delta_hc /= 100

# Work down (fine) to where we would round or ceil to max score
while check_score(handicap) > max_score - round_lim:
while check_score(handicap) > target:
handicap += delta_hc

handicap = handicap - delta_hc # Undo final iteration that overshoots
Expand Down

0 comments on commit a39d11e

Please sign in to comment.