diff --git a/run_game.py b/run_game.py index 62e3d9e..3455e9b 100644 --- a/run_game.py +++ b/run_game.py @@ -1,8 +1,24 @@ #!/usr/bin/env python3 +""" +AI Snake Game Runner + +This script provides the entry point for running the AI Snake Game. +It handles command-line arguments for different game modes and configurations. +""" + import argparse -from src.game import Game +from src import Game, GameMode def main(): + """ + Main entry point for the AI Snake Game. + + Parses command line arguments and initializes the game with the specified settings. + Available modes: + - Normal mode: Standard game settings + - Test mode: Smaller window and faster speed + - Debug mode: Shows grid and additional debug information + """ parser = argparse.ArgumentParser(description='Run AI Snake Game') parser.add_argument('--test', action='store_true', help='Run game in test mode (smaller window, faster speed)') @@ -25,10 +41,18 @@ def main(): # Apply debug mode settings if args.debug: - game.debug = True # Will need to add debug support to Game class + game.debug = True # Run the game - game.run() + try: + game.run() + except KeyboardInterrupt: + print("\nGame terminated by user") + except Exception as e: + print(f"Error: {e}") + finally: + # Clean up will be handled by Game class destructor + pass if __name__ == "__main__": main() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b7d1ed1 --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +setup( + name="ai-snake-game", + version="0.1.0", + author="Rbanh", + description="A classic snake game with AI capabilities", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://git.spacetrainclubhouse.com/Rbanh/AI-Snake-Game", + packages=find_packages(), + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 3 - Alpha", + "Topic :: Games/Entertainment :: Arcade", + ], + python_requires=">=3.8", + install_requires=[ + "pygame>=2.5.2", + "numpy>=1.24.3", + ], + extras_require={ + "dev": [ + "pytest>=7.4.3", + "pytest-xdist>=3.5.0", + "black>=23.12.1", + ], + }, + entry_points={ + "console_scripts": [ + "snake-game=run_game:main", + ], + }, +) \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py index 85a3fb9..d05a757 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,2 +1,30 @@ -# This file is intentionally empty. -# It marks the src directory as a Python package. \ No newline at end of file +""" +AI Snake Game - A classic snake game with AI capabilities. + +This package contains all the core game components including: +- Game engine and state management +- Snake movement and collision detection +- Food spawning system +- Menu interface +- AI controllers (coming soon) +""" + +from src.game import Game, GameState +from src.snake import Snake, Direction +from src.food import Food +from src.menu import Menu, GameMode, MenuItem + +__version__ = '0.1.0' +__author__ = 'Rbanh' + +# Define what's available when using "from src import *" +__all__ = [ + 'Game', + 'GameState', + 'Snake', + 'Direction', + 'Food', + 'Menu', + 'GameMode', + 'MenuItem' +] \ No newline at end of file diff --git a/src/game.py b/src/game.py index 37a5563..b11f088 100644 --- a/src/game.py +++ b/src/game.py @@ -1,9 +1,9 @@ import pygame import sys from enum import Enum, auto -from snake import Snake, Direction -from food import Food -from menu import Menu, GameMode +from src.snake import Snake, Direction +from src.food import Food +from src.menu import Menu, GameMode class GameState(Enum): MENU = auto() @@ -13,6 +13,12 @@ class GameState(Enum): class Game: def __init__(self): + # Initialize pygame and font system + if not pygame.get_init(): + pygame.init() + if not pygame.font.get_init(): + pygame.font.init() + # Initialize display self.width = 800 self.height = 600 diff --git a/tests/__init__.py b/tests/__init__.py index ba5fc7c..5c607dd 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,2 +1,19 @@ -# This file is intentionally empty. -# It marks the tests directory as a Python package for test discovery. \ No newline at end of file +""" +Test suite for the AI Snake Game. + +This package contains all test modules including: +- Unit tests for game components +- Integration tests for game mechanics +- Performance tests for AI algorithms +""" + +# Import test utilities and fixtures +from tests.conftest import game_config, mock_screen + +__version__ = '0.1.0' + +# Define test utilities available for import +__all__ = [ + 'game_config', + 'mock_screen' +] \ No newline at end of file