AI-Snake-Game/run_game.py

58 lines
1.7 KiB
Python

#!/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 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)')
parser.add_argument('--debug', action='store_true',
help='Run game in debug mode (shows grid and additional info)')
parser.add_argument('--ai-only', action='store_true',
help='Start directly in AI mode (skips menu)')
args = parser.parse_args()
# Create game instance
game = Game()
# Apply test mode settings
if args.test:
game.width = 400
game.height = 300
game.block_size = 20
game.fps = 30
# Apply debug mode settings
if args.debug:
game.debug = True
# Run the game
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()