from blokus_gym.core.bots import GreedyBot, GreedyCornersBot, MinimaxBot, RandomBot
from blokus_gym.core.pieces import DUO_PIECES, JUNIOR_PIECES, STANDARD_PIECES
from blokus_gym.envs.blokus_env import BlokusEnv
from blokus_gym.envs.multiagent import BlokusMultiAgentEnv

__all__ = [
    "BlokusEnv",
    "BlokusMultiAgentEnv",
    "STANDARD_PIECES",
    "DUO_PIECES",
    "JUNIOR_PIECES",
    "RandomBot",
    "GreedyBot",
    "GreedyCornersBot",
    "MinimaxBot",
]


def _register_envs():
    """Register all predefined environment configurations."""
    import gymnasium as gym

    # Standard 4-player Blokus (20x20)
    gym.register(
        id="Blokus-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 4,
            "board_size": 20,
            "pieces": STANDARD_PIECES,
        },
        max_episode_steps=500,
    )

    # Blokus Duo (2 players, 14x14)
    gym.register(
        id="BlokusDuo-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 2,
            "board_size": 14,
            "pieces": DUO_PIECES,
        },
        max_episode_steps=300,
    )

    # Blokus Junior (2 players, 14x14, simplified pieces)
    gym.register(
        id="BlokusJunior-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 2,
            "board_size": 14,
            "pieces": JUNIOR_PIECES,
        },
        max_episode_steps=200,
    )

    # Simple test env (2 players, 7x7, only small pieces)
    gym.register(
        id="BlokusSimple-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 2,
            "board_size": 7,
            "pieces": [p for p in STANDARD_PIECES if p.size < 5],
        },
        max_episode_steps=100,
    )

    # Greedy bot variants
    gym.register(
        id="BlokusGreedy-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 4,
            "board_size": 20,
            "pieces": STANDARD_PIECES,
            "bot_type": GreedyBot,
        },
        max_episode_steps=500,
    )

    gym.register(
        id="BlokusDuoGreedy-v0",
        entry_point="blokus_gym.envs:BlokusEnv",
        kwargs={
            "num_players": 2,
            "board_size": 14,
            "pieces": DUO_PIECES,
            "bot_type": GreedyBot,
        },
        max_episode_steps=300,
    )


_register_envs()
