コード例 #1
0
def ban_kyurem(tiers):
    elements = tiers.findall(".//tier")
    new_bans = set(("Kyurem-W", "Kyurem-B"))
    for element in elements:
        tier = element.attrib["name"]
        gen = element.attrib["gen"]
        if gen != "5": continue
        current_bans = deserialize_bans(element.attrib["pokemons"])
        bans = copy(current_bans)
        p = element
        while 1: 
            parent = p.attrib["banParent"] if "banParent" in p.attrib else None
            if not parent:
                break
            print("Adding {parent} to {tier}'s bans".format(parent=parent,tier=tier))
            p = tiers.find(".//tier[@name='{parent}']".format(parent=parent))
            bans |= deserialize_bans(p.attrib["pokemons"])

        ban_subset = new_bans - bans
        if ban_subset:
            print("Add bans for {pokemon} in {tier}.".format(pokemon=ban_subset, tier=tier))
            ans = input("Proceed with changes? [Y/n] ")
            if ans == "" or ans.upper().startswith("Y"):
                current_bans |= ban_subset
                element.attrib["pokemons"] = serialize_bans(bans)
                print("Tier {tier} updated!".format(tier=tier))
            else:
                print("Tier {tier} not updated.".format(tier=tier))
        else:
            print("Tier {tier} has bans already.".format(tier=tier))

    return tiers
コード例 #2
0
ファイル: updatepotiers.py プロジェクト: Neosweiss/Scripts
def ban_kyurem(tiers):
    elements = tiers.findall(".//tier")
    new_bans = set(("Kyurem-W", "Kyurem-B"))
    for element in elements:
        tier = element.attrib["name"]
        gen = element.attrib["gen"]
        if gen != "5": continue
        current_bans = deserialize_bans(element.attrib["pokemons"])
        bans = copy(current_bans)
        p = element
        while 1: 
            parent = p.attrib["banParent"] if "banParent" in p.attrib else None
            if not parent:
                break
            print("Adding {parent} to {tier}'s bans".format(parent=parent,tier=tier))
            p = tiers.find(".//tier[@name='{parent}']".format(parent=parent))
            bans |= deserialize_bans(p.attrib["pokemons"])

        ban_subset = new_bans - bans
        if ban_subset:
            print("Add bans for {pokemon} in {tier}.".format(pokemon=ban_subset, tier=tier))
            ans = input("Proceed with changes? [Y/n] ")
            if ans == "" or ans.upper().startswith("Y"):
                current_bans |= ban_subset
                element.attrib["pokemons"] = serialize_bans(bans)
                print("Tier {tier} updated!".format(tier=tier))
            else:
                print("Tier {tier} not updated.".format(tier=tier))
        else:
            print("Tier {tier} has bans already.".format(tier=tier))

    return tiers
コード例 #3
0
def update_tiers(tiers):
    for USAGE_TREE in TIER_TREES:
        all_bans = set(BANLIST.get(USAGE_TREE[0],[]))
        tier_usage = {}
        tier_pokemon = {}
        ban_parent = None
        grand_ban_parent = None
        for tier in USAGE_TREE:
            # Find bans by parent tier top usage
            top_usage = set()
            print("Calculating banlists for {tier}...".format(tier=tier), end = " ")
            if ban_parent:
                print("Downloading ranked stats for {tier}...".format(tier=ban_parent), end=" ")
                stats = get_ranked_stats(ban_parent)
                tier_usage[ban_parent] = dict((s[0], float(s[1])) for s in stats)

                cutoff = SPECIAL_CUTOFFS.get(tier, DEFAULT_CUTOFF)
                tier_pokemon[ban_parent] = [entry[0] for entry in stats if float(entry[1]) >= cutoff]

            # Bans 
            parent_pokemon = tier_pokemon[ban_parent] if ban_parent else set()
            usage_bans = set(parent_pokemon) 
            banlist_bans = set(BANLIST.get(tier,[])) | set(ADDITIONAL_BANS.get(tier,[]))
            pokemon_bans = usage_bans | banlist_bans

            element = tiers.find(".//tier[@name='{tier}']".format(tier=tier))
 
            drops = set()
            if grand_ban_parent:
                # Calculate drops using very heuristic approach.
                for pokemon in tier_usage[grand_ban_parent]:
                    if pokemon not in (all_bans | pokemon_bans) and 0.1 < tier_usage[grand_ban_parent][pokemon] < SPECIAL_CUTOFFS.get(ban_parent, DEFAULT_CUTOFF) and tier_usage[ban_parent].get(pokemon, 0) * 20 < tier_usage[grand_ban_parent][pokemon]:
                        drops.add(pokemon)
            pokemon_bans |= drops            
 
            current_bans = deserialize_bans(element.attrib["pokemons"])
            all_bans = all_bans | pokemon_bans
            missing_bans = pokemon_bans - current_bans
            extra_bans = current_bans - pokemon_bans
            likely_drops = current_bans - all_bans
            removable_bans = extra_bans - likely_drops
            print("Calculated.")
 
            if drops:
                print("Likely dropped from {grand_parent} to {parent}: {pokes}. Added to {tier} ban list.".format(pokes=drops, grand_parent=grand_ban_parent, parent=ban_parent, tier=tier))
            if missing_bans or removable_bans or likely_drops:
                bans = copy(current_bans)
                print("Proposed changes:")
                for reason, missing_subset in (("usage", usage_bans), ("banlist", banlist_bans), ("dropping from grandparent", drops)):
                    ban_subset = missing_subset - current_bans
                    if ban_subset:
                        print("Add bans for {pokemon} as they should be banned by {reason}.".format(pokemon=ban_subset, reason=reason))
                        ans = input("Proceed with changes? [Y/n] ")
                        if ans == "" or ans.upper().startswith("Y"):
                            bans |= ban_subset

                if removable_bans:
                    print("Remove bans for {extra} as they are banned in parent tiers.".format(extra=removable_bans))
                    ans = input("Proceed with changes? [Y/n] ")
                    if ans == "" or ans.upper().startswith("Y"):
                        bans -= removable_bans

                if likely_drops:
                    print("These pokemon have fell in usage or have been removed from banlist {bans} and their bans are to be removed.".format(bans=likely_drops))
                    ans = input("Proceed with changes? [Y/n] ")
                    if ans == "" or ans.upper().startswith("Y"):
                        bans -= likely_drops 

                if bans != current_bans:
                    element.attrib["pokemons"] = serialize_bans(bans)
                    print("Tier {tier} updated!".format(tier=tier))
                else:
                    print("Tier {tier} not updated.".format(tier=tier))
            else:
                print("Tier {tier} seems fine.".format(tier=tier))
            grand_ban_parent = ban_parent
            ban_parent = tier

    return tiers
コード例 #4
0
ファイル: updatepotiers.py プロジェクト: Neosweiss/Scripts
def update_tiers(tiers):
    for USAGE_TREE in TIER_TREES:
        all_bans = set(BANLIST.get(USAGE_TREE[0],[]))
        tier_usage = {}
        tier_pokemon = {}
        ban_parent = None
        grand_ban_parent = None
        for tier in USAGE_TREE:
            # Find bans by parent tier top usage
            top_usage = set()
            print("Calculating banlists for {tier}...".format(tier=tier), end = " ")
            if ban_parent:
                print("Downloading ranked stats for {tier}...".format(tier=ban_parent), end=" ")
                stats = get_ranked_stats(ban_parent)
                tier_usage[ban_parent] = dict((s[0], float(s[1])) for s in stats)

                cutoff = SPECIAL_CUTOFFS.get(tier, DEFAULT_CUTOFF)
                tier_pokemon[ban_parent] = [entry[0] for entry in stats if float(entry[1]) >= cutoff]

            # Bans 
            parent_pokemon = tier_pokemon[ban_parent] if ban_parent else set()
            usage_bans = set(parent_pokemon) 
            banlist_bans = set(BANLIST.get(tier,[])) | set(ADDITIONAL_BANS.get(tier,[]))
            pokemon_bans = usage_bans | banlist_bans

            element = tiers.find(".//tier[@name='{tier}']".format(tier=tier))
 
            drops = set()
            if grand_ban_parent:
                # Calculate drops using very heuristic approach.
                for pokemon in tier_usage[grand_ban_parent]:
                    if pokemon not in (all_bans | pokemon_bans) and 0.1 < tier_usage[grand_ban_parent][pokemon] < SPECIAL_CUTOFFS.get(ban_parent, DEFAULT_CUTOFF) and tier_usage[ban_parent].get(pokemon, 0) * 20 < tier_usage[grand_ban_parent][pokemon]:
                        drops.add(pokemon)
            pokemon_bans |= drops            
 
            current_bans = deserialize_bans(element.attrib["pokemons"])
            all_bans = all_bans | pokemon_bans
            missing_bans = pokemon_bans - current_bans
            extra_bans = current_bans - pokemon_bans
            likely_drops = current_bans - all_bans
            removable_bans = extra_bans - likely_drops
            print("Calculated.")
 
            if drops:
                print("Likely dropped from {grand_parent} to {parent}: {pokes}. Added to {tier} ban list.".format(pokes=drops, grand_parent=grand_ban_parent, parent=ban_parent, tier=tier))
            if missing_bans or removable_bans or likely_drops:
                bans = copy(current_bans)
                print("Proposed changes:")
                for reason, missing_subset in (("usage", usage_bans), ("banlist", banlist_bans), ("dropping from grandparent", drops)):
                    ban_subset = missing_subset - current_bans
                    if ban_subset:
                        print("Add bans for {pokemon} as they should be banned by {reason}.".format(pokemon=ban_subset, reason=reason))
                        ans = input("Proceed with changes? [Y/n] ")
                        if ans == "" or ans.upper().startswith("Y"):
                            bans |= ban_subset

                if removable_bans:
                    print("Remove bans for {extra} as they are banned in parent tiers.".format(extra=removable_bans))
                    ans = input("Proceed with changes? [Y/n] ")
                    if ans == "" or ans.upper().startswith("Y"):
                        bans -= removable_bans

                if likely_drops:
                    print("These pokemon have fell in usage or have been removed from banlist {bans} and their bans are to be removed.".format(bans=likely_drops))
                    ans = input("Proceed with changes? [Y/n] ")
                    if ans == "" or ans.upper().startswith("Y"):
                        bans -= likely_drops 

                if bans != current_bans:
                    element.attrib["pokemons"] = serialize_bans(bans)
                    print("Tier {tier} updated!".format(tier=tier))
                else:
                    print("Tier {tier} not updated.".format(tier=tier))
            else:
                print("Tier {tier} seems fine.".format(tier=tier))
            grand_ban_parent = ban_parent
            ban_parent = tier

    return tiers