def dynamic_timeout_formular(min_votes, votes_fraction):
"""
Formula used for dynamic timeout
:param min_votes:
:param votes_fraction:
:return:
"""
if votes_fraction >= 1:
return 1 / votes_fraction # Reduce timeout if more people than necessary voted
result = 1
result += (1 - votes_fraction) * math.log2(min_votes) # Linear part makes timeout rise
result += min_votes * (
min_votes ** ((1 - votes_fraction) ** 3) - 1) # Exponential part to punish really low vote counts
result += (40 - 40 ** (votes_fraction)) / min_votes ** 2 # Punish missing votes harder if min_votes is low
return result
评论列表
文章目录