Skip to content

Models

Core data models shared across the entire package.

models

Shared data models used across the entire simulator.

Move dataclass

Move(
    name: str,
    type_: str,
    category: str,
    power: int,
    accuracy: int,
    pp: int,
    status_effect: str | None = None,
    stat_changes: dict = dict(),
)

A single move a Pokemon can use in battle.

score

score(
    user_types: list[str],
    defender_types: list[str],
    type_chart: TypeChart,
) -> float

Scoring heuristic used by the AI to pick moves.

Source code in pokerena/models.py
def score(
    self, user_types: list[str], defender_types: list[str], type_chart: TypeChart
) -> float:  # noqa: F821
    """Scoring heuristic used by the AI to pick moves."""
    if self.category == "status":
        return 0.0
    stab = 1.5 if self.type_ in user_types else 1.0
    effectiveness = type_chart.multiplier(self.type_, defender_types)
    acc = (self.accuracy / 100.0) if self.accuracy > 0 else 1.0
    return self.power * stab * effectiveness * acc

Pokemon dataclass

Pokemon(
    name: str,
    types: list[str],
    base_stats: dict,
    moves: list[Move],
    generation: int,
    smogon_tier: str,
    bst: int,
    evo_line: list[str] = list(),
    evo_stage: int = 0,
    current_hp: int = 0,
    max_hp: int = 0,
    stats: dict = dict(),
    status: str | None = None,
    status_counter: int = 0,
    stat_stages: dict = dict(),
)

A single Pokemon participant with stats, moves, and battle state.

__post_init__

__post_init__() -> None

Recompute BST from base_stats after dataclass init.

Source code in pokerena/models.py
def __post_init__(self) -> None:
    """Recompute BST from base_stats after dataclass init."""
    self.bst = sum(self.base_stats.values())

is_fainted

is_fainted() -> bool

Return True if this Pokemon has no HP remaining.

Source code in pokerena/models.py
def is_fainted(self) -> bool:
    """Return True if this Pokemon has no HP remaining."""
    return self.current_hp <= 0

stage_multiplier

stage_multiplier(stat: str) -> float

Return the stat stage multiplier for the given stat name.

Source code in pokerena/models.py
def stage_multiplier(self, stat: str) -> float:
    """Return the stat stage multiplier for the given stat name."""
    stage = self.stat_stages.get(stat, 0)
    if stage >= 0:
        return (2 + stage) / 2.0
    return 2.0 / (2 - stage)