Skip to content

Instantly share code, notes, and snippets.

@lavaboom
Last active July 15, 2019 18:33
Show Gist options
  • Select an option

  • Save lavaboom/8a9dfd0fc2b51a0c6be86173feeb3317 to your computer and use it in GitHub Desktop.

Select an option

Save lavaboom/8a9dfd0fc2b51a0c6be86173feeb3317 to your computer and use it in GitHub Desktop.

Revisions

  1. lavaboom revised this gist Jul 15, 2019. 1 changed file with 2 additions and 14 deletions.
    16 changes: 2 additions & 14 deletions slot_utils.py
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,6 @@
    def get_average_stat(times, func, params):
    '''
    run <func> <times> with given <params> and return the average statistics
    '''
    tally = 0.0
    for i in range(times): tally += func(params)
    print('Average stat: {}'.format(tally/times))
    return tally/times


    def get_random_option_from_weight(options, weights):
    '''
    python 3.6 and later
    '''
    from random import choices
    options = [1, 2, 3, 4, 5, 6]
    weights = [0.1, 0.05, 0.05, 0.2, 0.4, 0.2]
    return choices(options, weights)
    import random
    return random.choices(options, weights)[0]
  2. lavaboom revised this gist Jul 15, 2019. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion slot_utils.py
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,14 @@ def get_average_stat(times, func, params):
    tally = 0.0
    for i in range(times): tally += func(params)
    print('Average stat: {}'.format(tally/times))
    return tally/times
    return tally/times


    def get_random_option_from_weight(options, weights):
    '''
    python 3.6 and later
    '''
    from random import choices
    options = [1, 2, 3, 4, 5, 6]
    weights = [0.1, 0.05, 0.05, 0.2, 0.4, 0.2]
    return choices(options, weights)
  3. lavaboom created this gist Jul 15, 2019.
    8 changes: 8 additions & 0 deletions slot_utils.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    def get_average_stat(times, func, params):
    '''
    run <func> <times> with given <params> and return the average statistics
    '''
    tally = 0.0
    for i in range(times): tally += func(params)
    print('Average stat: {}'.format(tally/times))
    return tally/times