podaboutlist / santa

Discord bot for sending and collecting gifts
https://podaboutli.st/discord
GNU Affero General Public License v3.0
1 stars 3 forks source link

[bot] Rewrite "Grinch Chance" algorithm #19

Closed RalphORama closed 3 years ago

RalphORama commented 3 years ago

Description of the Bug

The current algorithm for predicting the chance of the Grinch visiting the user seems to result in a very high visit rate (only tested at a lower number of gifts). See the current implementation here

My current implementation for the Grinch Visit algorithm is:

def calc_steal_chance() -> bool:
    # Generate a number between 0 and the # of presents the User currently owns
    rand_int = random.randint(0, current_present_count)
    # Take the cube root of the User's present count
    threshold = int(present_count ** (1 / 3))
    # If the user said 'Please', give them a 5% better chance at not failing the check
    threshold = threshold * 1.05 if please else threshold
    # If rand_int > threshold, steal presents
    return rand_int > threshold

The logic behind this was to use cube root falloff so as a user's present count gets higher, the threshold determined via cube root levels off (see graph).

Cube root vs y=x

However, this dropoff is way too fast. Gotta rewrite the algo.

Steps to Reproduce the Bug

n/a

The Bug Affects

RalphORama commented 3 years ago

good results for sqrt(40x) - 10 if we set the "low gift threshold" to 15

Screen Shot 2020-12-14 at 1 50 44 AM