Skip to content

Smogon tiers

Loads and parses Smogon tier assignments from Pokemon Showdown's formats-data.ts source files on GitHub.

Supports Gens 1-9. Falls back to a hard-coded Gen 1 tier map if the network is unavailable, and defaults all other gens to OU on failure.

smogon

Smogon tier data loader.

Smogon tier lists are stored as JSON under cache/smogon/gen{N}_tiers.json. Format expected: { "pokemon_name": "tier_name", ... } where tier_name is one of: ubers, ou, uu, ru, nu, pu

If no cached file exists for a generation, a bundled fallback is used that maps all Pokemon to "ou" so the simulator can still run (with a warning). The --fetch flag triggers re-downloading from the authoritative source.

smogon/pokemon-showdown on GitHub:

Gen 1-8: https://raw.githubusercontent.com/smogon/pokemon-showdown/master/data/mods/gen{N}/formats-data.ts Gen 9: https://raw.githubusercontent.com/smogon/pokemon-showdown/master/data/formats-data.ts

load_tiers

load_tiers(
    gen: int, force_fetch: bool = False
) -> dict[str, str]

Return a dict mapping pokemon_name (lower-case) -> tier (lower-case). Falls back to built-in Gen 1 data if fetch fails.

Source code in pokerena/data/smogon.py
def load_tiers(gen: int, force_fetch: bool = False) -> dict[str, str]:
    """
    Return a dict mapping pokemon_name (lower-case) -> tier (lower-case).
    Falls back to built-in Gen 1 data if fetch fails.
    """
    cache_key = f"gen{gen}_tiers"
    if not force_fetch:
        cached = disk_cache.get("smogon", cache_key)
        if cached is not None:
            return cached  # type: ignore[return-value]

    # Try to fetch from smogon/pokemon-showdown repo
    try:
        import requests

        url = _SMOGON_URLS.get(gen)
        if url:
            resp = requests.get(url, timeout=10)
            resp.raise_for_status()
            tiers = _parse_ps_formats_data(resp.text)
            disk_cache.put("smogon", cache_key, tiers)
            log.info("Smogon tier data fetched for Gen %d (%d entries)", gen, len(tiers))
            return tiers
    except Exception as exc:  # noqa: BLE001
        log.warning("Could not fetch Smogon tier data for Gen %d: %s", gen, exc)

    # Fall back to built-ins for Gen 1
    if gen == 1:
        log.warning("Using built-in Gen 1 tier fallback.")
        return _build_gen1_fallback()

    log.warning("No tier data available for Gen %d -- defaulting all to OU.", gen)
    return {}

assign_tier

assign_tier(
    name: str, tier_map: dict[str, str], default: str = "nu"
) -> str

Return the tier for a Pokemon name, falling back to default if not found. Validated against TIERS list.

Source code in pokerena/data/smogon.py
def assign_tier(name: str, tier_map: dict[str, str], default: str = "nu") -> str:
    """
    Return the tier for a Pokemon name, falling back to default if not found.
    Validated against TIERS list.
    """
    tier = tier_map.get(_normalize_name(name), default)
    if tier not in TIERS:
        return default
    return tier