Skip to content

System Architecture

Overview

The Path (AI-Pi) uses a modular architecture designed for edge AI gaming, with clear separation between game logic, AI processing, and data management.

System Components

graph TD
    A[Game Client] --> B[Game Server]
    B --> C[AI Engine]
    C --> D[AI HAT+]
    B --> E[Data Store]
    C --> E

Core Components

  1. Game Server (Go)
  2. Handles game state management
  3. WebSocket communication
  4. JSON state serialization
  5. Turn sequencing
  6. Action validation

  7. AI Engine (Python)

  8. TensorFlow Lite inference
  9. Dynamic difficulty (0.2-0.95)
  10. Personality system
  11. Training pipeline (Mac Mini M1)

  12. Game Client (TypeScript)

  13. React with Material-UI
  14. Redux state management
  15. WebSocket communication
  16. Simple battle UI

  17. Hardware Layer

  18. Raspberry Pi 5 (8GB)
  19. AI HAT+ acceleration
  20. Active cooling
  21. Local storage

Data Flow

  1. Game State Management

    Client Action -> Server Validation -> State Update -> AI Processing -> Response
    

  2. AI Decision Pipeline

    State Input -> Feature Extraction -> TFLite Inference -> Action Selection -> Validation
    

  3. Battle System

    User Login -> Create/Join Battle -> Turn Exchange -> Battle End -> Stats Update
    

Integration Points

1. Server-Client

interface GameConnection {
    // WebSocket connection for battle management
    connect(token: string): Promise<void>
    createBattle(): Promise<string>
    joinBattle(battleId: string): Promise<void>
    submitAction(action: GameAction): Promise<void>
    forfeit(): Promise<void>
    onStateUpdate(handler: (state: GameState) => void): void
}

2. Server-AI

class AIInterface:
    """AI engine interface"""
    async def process_turn(
        self, 
        state: GameState,
        difficulty: float
    ) -> GameAction:
        """Process game state and return next action"""

3. Client UI States

interface UIState {
    // Simple UI states
    isPlayerTurn: boolean
    isWaiting: boolean
    availableActions: string[]
    battleStatus: 'active' | 'victory' | 'defeat'
}

Performance Considerations

  1. AI Processing
  2. TensorFlow Lite optimization
  3. Batch inference when needed
  4. Simple state management

  5. Client Interface

  6. Material-UI components
  7. Basic animations for state changes
  8. Disabled controls during AI turns

  9. Data Management

  10. Local game state
  11. Basic user authentication
  12. Battle history storage