#!/usr/bin/env python3
"""Entry point for `python -m bvb` and `birds-vs-bats` CLI command."""

import os
import sys


def main():
    # Ensure the project root is on sys.path so `src.*` imports work
    pkg_dir = os.path.dirname(os.path.abspath(__file__))
    project_root = os.path.dirname(pkg_dir)

    # When installed via pip, config files live next to this package
    # When running from source, they live in project root
    # Try both locations
    for candidate in [pkg_dir, project_root, os.getcwd()]:
        config_path = os.path.join(candidate, 'config.yml')
        if os.path.exists(config_path):
            os.chdir(candidate)
            break

    if project_root not in sys.path:
        sys.path.insert(0, project_root)

    # Import and run the game
    from game import main as game_main
    game_main()


if __name__ == '__main__':
    main()
