How krish-om/agents-in-ai works
Project type and purpose
• This is a standalone Python‐based game application (the classic Snake) augmented with multiple AI agent implementations, ranging from simple reflex to reinforcement learning.
• Its primary goal is educational: to demonstrate the evolution of intelligent agent architectures in a game environment and compare their performance.
File structure
• Top‐level
• run_agents.py – main entry point, orchestrates menu and agent selection
• core_game/ – the game engine (game loop, rendering, collision detection, audio)
• agents/ – five subpackages, each implementing a distinct AI agent architecture
• resources/ – game audio assets
• reports/ – generated performance reports
• ss/ – screenshots
• requirements.txt, README.md, AI LAB1.1.pdf – documentation and dependencies
• agents/
• simple_reflex/
• goal_based/
• model_based/
• utility_based/
• q_learning/ (contains both training scripts and trained data JSON files)
• Notice the separation: a core game engine module and a plug-in style agent interface.
README for additional insights
• Confirms five AI paradigms: reflex, goal‐based (A*), model‐based, utility‐based, Q‐learning (with training pipeline).
• Core engine interface is in core_game/source.py—each agent module imports this to receive perceptions and execute actions.
• Training artifacts (trained_q_table.json, training_stats.json) and reports are generated in dedicated folders.
a. Main components
• Run_Agents Orchestrator
• Core Game Engine
• Agent Interface Layer
• Q-Learning Training Pipeline
• Data Storage (Q-table JSON, stats JSON)
• Resources (Audio)
• Reports Generator
b. Relationships & interactions
• Run_Agents → CoreGame: initializes engine and passes control
• CoreGame ↔ Agent Interface: every game tick, engine sends game state (perceptions) to the selected agent; agent returns an action
• Agent Implementations plug into the interface (polymorphic module loading)
• Q-Learning Trainer → Q-Learning Agent: trainer runs many game sessions via CoreGame, collects experience, updates Q-table → writes JSON
• Trained Player loads JSON → plays via CoreGame
• CoreGame triggers audio via Resources
• Reports scripts parse training_stats.json and gameplay logs → Reports
c. Architectural patterns & design principles
• Plug-in architecture for agents (each in its own package, shares a common API)
• Separation of concerns: game mechanics vs. AI logic vs. training vs. reporting
• Data persistence layer for learning (JSON store)
d. Key technologies/frameworks
• Python 3.8+
• Pygame (rendering, input, audio)
• json (Q-table and statistics persistence)
• Standard libs: os, sys, random, time, math