<commit_before>"""Experience Tables
"""

#Build out experience tables for use in the experience module<commit_msg>Add experience table<commit_after>"""Pokemon Experience Tables
"""

class ExperienceTables:
    'The table is a dictionary of the groups with a dictionary of levels'

    def __init__(self):
        #Level 1 included by default.
        self.exp_tables = {'erratic'     : {0 : 1},
                           'fast'        : {0 : 1},
                           'medium_fast' : {0 : 1},
                           'medium_slow' : {0 : 1},
                           'slow'        : {0 : 1},
                           'fluctuating' : {0 : 1},
                          }

        self.build_tables()

    def build_tables(self):
        'Fills out the exp_tables dictionary with all groups and levels'

        #erratic
        for level in range(2, 102):
            if level <= 50:
                self.exp_tables['erratic'][int(\
                    (1/50) * ((level ** 3) * (100 - level)))] = level
            elif level <= 68:
                self.exp_tables['erratic'][int(\
                    (1/100) * ((level ** 3) * (150 - level)))] = level
            elif level <= 98:
                self.exp_tables['erratic'][int(\
                    (1/500) * ((level ** 3) * ((1911 - 10 * level) / 3)))] = level
            else:
                self.exp_tables['erratic'][int(\
                    (1/100) * ((level ** 3) * (160 - level)))] = level

        #fast
        for level in range(2, 102):
            self.exp_tables['fast'][int((4 * level ** 3) / 5)] = level

        #medium_fast
        for level in range(2, 102):
            self.exp_tables['medium_fast'][int(level ** 3)] = level

        #medium_slow
        for level in range(2, 102):
            self.exp_tables['medium_slow'][int(\
                ((6 / 5) * level ** 3) - (15 * level ** 2) + (100 * level) - 140)] = level

        #slow
        for level in range(2, 102):
            self.exp_tables['slow'][int((5 * level ** 3) / 4)] = level

        #fluctuating
        for level in range(2, 102):
            if level <= 15:
                self.exp_tables['fluctuating'][int(level ** 3 * \
                    ((((level + 1) / 3) + 24) / 50))] = level
            elif level <= 36:
                self.exp_tables['fluctuating'][int(level ** 3 * \
                    ((level + 14) / 50))] = level
            else:
                self.exp_tables['fluctuating'][int(level ** 3 * \
                    (((level / 2) + 32) / 50))] = level

    def level_lookup(self, group, experience):
        'Takes in a group and experience, returns a level'
        estimate = 1
        for key in self.exp_tables[group]:
            if key <= experience:
                estimate += 1
            else:
                return estimate - 1

if __name__ == '__main__':
    a = ExperienceTables()
    print('all results should be 42')
    print(a.exp_tables['erratic'][85942], a.exp_tables['fast'][59270],
          a.exp_tables['medium_fast'][74088], a.exp_tables['medium_slow'][66505],
          a.exp_tables['slow'][92610], a.exp_tables['fluctuating'][78533])
    print(a.level_lookup('slow', 95000))
{'fraction_non_alphanumeric': 0.14577442664153314, 'fraction_numerical': 0.04995287464655985, 'mean_word_length': 1.5739692805173808, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5773962', 'n_tokens_mistral': 1067, 'n_tokens_neox': 927, 'n_words': 245}