<commit_before>from random import randint

from data.moves import Moves
from data.pokedex import Pokedex
from data.types import Types

blacklist = {'focuspunch','fakeout','snore','dreameater','lastresort','explosion','selfdestruct','synchronoise','belch','trumphcard','wringout'}
chargemoves = {'hyperbeam','gigaimpact','frenzyplant','blastburn','hydrocannon','rockwrecker','roaroftime','bounce','dig','dive','fly','freezeshock','geomancy','iceburn','phantomforce','razorwind','shadowforce','skullbash','skyattack','skydrop','solarbeam'}
def getMove(moves, pokemon, opponent):
    # Moves is a list of 4 moves, possibly good or bad moves...
    options = []
    for m in moves:
        m = m.replace('-','')
        if m in blacklist or m in chargemoves:
            continue
        # Anything under 40 base power is probably useless (priority is 40)
        if (Moves[m]['basePower'] > 40 or m in ['grass knot', 'low kick']):
            options.append(m)
        if Moves[m]['type'] in Pokedex[pokemon.species]['types'] and Moves[m]['basePower'] > 30:
            options.append(m)
        if m not in options:
            continue
        # Resisted moves get 0 or 1 entry (1 only if STAB and over 40 base power)
        if len(Pokedex[opponent.species]['types']) > 1:
            types = Pokedex[opponent.species]['types']
            eff = Types[types[0]][Moves[m]['type']] * Types[types[1]][Moves[m]['type']]
            if eff < 1:
                options.remove(m)
        else:
            eff = Types[ Pokedex[opponent.species]['types'][0] ][Moves[m]['type']]
            if eff > 1:
                options.remove(m)
    if len(options) == 0:
        return moves[randint(0, len(moves)-1)]
    # This will pick moves that have a much higher possible damage output than guessing
    # since it will always use the better attacking stat (hopefully with a good base power move)
    for o in options:
        if pokemon.stats['atk'] > (40 + pokemon.stats['spa']) and Moves[m]['category'] == 'Physical':
            return o
        if (pokemon.stats['atk'] + 40) < pokemon.stats['spa'] and Moves[m]['category'] == 'Special':
            return o
    return options[randint(0, len(options)-1)]
        
def getLead(team, opposing):
    scores = {}
    for mon in team:
        scores[mon] = 0
        moves = team[mon].moves
        for opp in opposing:
            for move in moves:
                scores[mon] += calcScore(move, team[mon], opp)
    try:
        m = max(scores.values())
        options = [poke for poke,score in scores.items() if score == m]
        return team[options[randint(0,len(options)-1)]].teamSlot<commit_msg>Fix test for resists and higher the gap for only picking one type of moves<commit_after>from random import randint

from data.moves import Moves
from data.pokedex import Pokedex
from data.types import Types

blacklist = {'focuspunch','fakeout','snore','dreameater','lastresort','explosion','selfdestruct','synchronoise','belch','trumphcard','wringout'}
chargemoves = {'hyperbeam','gigaimpact','frenzyplant','blastburn','hydrocannon','rockwrecker','roaroftime','bounce','dig','dive','fly','freezeshock','geomancy','iceburn','phantomforce','razorwind','shadowforce','skullbash','skyattack','skydrop','solarbeam'}
def getMove(moves, pokemon, opponent):
    # Moves is a list of 4 moves, possibly good or bad moves...
    options = []
    for m in moves:
        m = m.replace('-','')
        if m in blacklist or m in chargemoves:
            continue
        # Anything under 40 base power is probably useless (priority is 40)
        if (Moves[m]['basePower'] > 40 or m in ['grass knot', 'low kick']):
            options.append(m)
        if Moves[m]['type'] in Pokedex[pokemon.species]['types'] and Moves[m]['basePower'] > 30:
            options.append(m)
        if m not in options:
            continue
        # Resisted moves get 0 or 1 entry (1 only if STAB and over 40 base power)
        if len(Pokedex[opponent.species]['types']) > 1:
            types = Pokedex[opponent.species]['types']
            eff = Types[types[0]][Moves[m]['type']] * Types[types[1]][Moves[m]['type']]
            if eff < 1:
                options.remove(m)
        else:
            eff = Types[ Pokedex[opponent.species]['types'][0] ][Moves[m]['type']]
            if eff < 1:
                options.remove(m)
    if len(options) == 0:
        return moves[randint(0, len(moves)-1)]
    # This will pick moves that have a much higher possible damage output than guessing
    # since it will always use the better attacking stat (hopefully with a good base power move)
    for o in options:
        if pokemon.stats['atk'] > (50 + pokemon.stats['spa']) and Moves[m]['category'] == 'Physical':
            return o
        if (pokemon.stats['atk'] + 50) < pokemon.stats['spa'] and Moves[m]['category'] == 'Special':
            return o
    return options[randint(0, len(options)-1)]
        
def getLead(team, opposing):
    scores = {}
    for mon in team:
        scores[mon] = 0
        moves = team[mon].moves
        for opp in opposing:
            for move in moves:
                scores[mon] += calcScore(move, team[mon], opp)
    try:
        m = max(scores.values())
        options = [poke for poke,score in scores.items() if score == m]
        return team[options[randint(0,len(options)-1)]].teamSlot
{'fraction_non_alphanumeric': 0.1450196225004672, 'fraction_numerical': 0.011960381237151934, 'mean_word_length': 2.9208791208791207, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '4800231', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1619, 'n_words': 461}