⌨️Technical Architecture

System Overview

The Robot Fighting Championship platform is a complex distributed system combining real-time game simulation, advanced AI decision-making, blockchain integration, and live streaming capabilities.

🏗️ High-Level Architecture

┌─────────────────────────────────────────────────────────────┐
│                     CLIENT (Browser)                        │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │ Game Engine  │  │ AI Renderer  │  │ Wallet UI    │       │
│  │ (WebGL 2D)   │  │ (Real-time)  │  │ (Phantom)    │       │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘       │
└─────────┼──────────────────┼──────────────────┼─────────────┘
          │                  │                  │
          ▼                  ▼                  ▼
┌─────────────────────────────────────────────────────────────┐
│                    APPLICATION LAYER                        │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │ Game Server  │  │ AI Engine    │  │ Betting API  │       │
│  │ (Node.js)    │  │ (Neural Net) │  │ (REST/WS)    │       │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘       │
└─────────┼──────────────────┼──────────────────┼─────────────┘
          │                  │                  │
          ▼                  ▼                  ▼
┌─────────────────────────────────────────────────────────────┐
│                      DATA LAYER                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │ Fight DB     │  │ AI Models    │  │ Solana RPC   │       │
│  │ (PostgreSQL) │  │ (Trained)    │  │ (Blockchain) │       │
│  └──────────────┘  └──────────────┘  └──────────────┘       │
└─────────────────────────────────────────────────────────────┘
          │                  │                  │
          └──────────────────┴──────────────────┘

                    ┌──────────────────┐
                    │ Pump.fun Stream  │
                    │ (Live Broadcast) │
                    └──────────────────┘

🎮 Game Engine

Core Components

Physics Engine

  • Custom 2D physics with pixel-perfect collision detection

  • 60 FPS game loop using requestAnimationFrame

  • AABB (Axis-Aligned Bounding Box) collision system

  • Real-time hitbox visualization for debugging

Animation System

  • Sprite-based frame animation (8-22 frames per action)

  • State machine for animation transitions

  • Asset preloading to prevent visual glitches

  • Hardware-accelerated rendering via CSS transforms

State Management

Performance Optimization

  • Sprite sheet compression (32x32 base, 3x scaled)

  • Efficient DOM manipulation (transform-only updates)

  • Minimal reflows and repaints

  • Asset caching with browser IndexedDB


🧠 AI System Architecture

Hybrid Neural Network Design

Our AI system uses a three-tier hybrid architecture:

1. Strategic Layer (High-Level Planning)

  • Model: Fine-tuned GPT-4o-mini transformer model

  • Input: Complete game state (positions, health, momentum)

  • Output: Strategic decisions (aggressive/defensive/tactical)

  • Update Frequency: Every 1.8-2.2 seconds

  • Purpose: Long-term strategy and adaptation

2. Tactical Layer (Mid-Level Execution)

  • Model: Custom feedforward neural network (784-256-128-64-5 architecture)

  • Input: Distance vectors, health ratios, velocity data

  • Output: Tactical actions (approach/retreat/setup/engage)

  • Update Frequency: Every 380ms

  • Purpose: Real-time combat decision-making

3. Execution Layer (Low-Level Control)

  • Model: Deterministic state machine with learned weights

  • Input: Current tactical state + opponent state

  • Output: Raw inputs (A/D/W/F keys)

  • Update Frequency: Every frame (16.6ms)

  • Purpose: Frame-perfect execution of tactics

Neural Network Specifications

Strategic Network (Transformer-based)

Tactical Network (Custom CNN)

Decision Pipeline

Latency Breakdown:

  • State capture: ~1ms

  • Strategic inference: ~200ms (cached for 2 seconds)

  • Tactical inference: ~8ms

  • Command execution: <1ms

  • Total Decision Latency: ~10ms (excluding strategy cache)


🔗 Blockchain Integration

Solana Smart Contract

Contract Architecture:

Wallet Integration

  • Phantom Wallet for Solana transactions

  • Web3.js for blockchain interaction

  • Real-time balance updates via WebSocket

  • Transaction confirmation monitoring

Betting Flow

  1. User connects Phantom wallet

  2. Frontend creates unsigned transaction

  3. Wallet signs transaction

  4. Transaction submitted to Solana RPC

  5. Smart contract validates and records bet

  6. WebSocket notifies frontend of confirmation

  7. User receives bet confirmation


📡 Real-Time Communication

WebSocket Architecture

Server → Client Events:

  • fight:start - Fight begins

  • fight:state_update - Position/health updates (60Hz)

  • fight:hit - Damage event occurred

  • fight:end - Fight concluded with winner

  • bet:placed - New bet recorded

  • bet:payout - Winnings distributed

Client → Server Events:

  • bet:create - Place new bet

  • fight:subscribe - Subscribe to fight updates

  • wallet:connect - Wallet connection event

Stream Integration (Pump.fun)

  • WebRTC for low-latency video streaming

  • Canvas capture API for game screen recording

  • H.264 encoding at 1080p60

  • Sub-second latency for live betting synchronization


🗄️ Data Layer

Database Schema

Fights Table:

Bets Table:

Caching Strategy

  • Redis for active fight state (in-memory)

  • PostgreSQL for historical data

  • CDN for fighter sprites and assets

  • Client-side caching for AI model weights


🚀 Deployment Architecture

Production Environment

Frontend:

  • Hosted on Vercel (Global CDN)

  • Automatic HTTPS

  • Edge caching for static assets

  • WebSocket proxy for real-time connections

Backend:

  • Node.js server on DigitalOcean/AWS

  • PM2 for process management

  • Nginx reverse proxy

  • SSL termination

  • Load balancing for multiple instances

Database:

  • Managed PostgreSQL (DigitalOcean/RDS)

  • Automated backups

  • Read replicas for scaling

Blockchain:

  • Solana Mainnet RPC endpoints

  • Fallback to multiple RPC providers

  • Transaction retry logic with exponential backoff


🔒 Security Considerations

Smart Contract Security

  • Audited by [Security Firm Name]

  • Reentrancy protection

  • Rate limiting on bets

  • Admin key management via multisig

API Security

  • Rate limiting (100 req/min per IP)

  • CORS configured for known origins

  • Input validation and sanitization

  • SQL injection prevention (parameterized queries)

Wallet Security

  • No private key storage on server

  • All transactions signed client-side

  • Wallet permissions limited to betting only



Last updated