warfactoryracine/docs/serveur/README.md
StillHammer bb92e9dc93 Add comprehensive engine-focused documentation structure
📚 Complete documentation reorganization:

🗂️ Structure:
- docs/global/ → Complete project documentation (all original files)
- docs/engines/ → 10 engine-specific docs with focused responsibilities
- docs/serveur/ → Server coordinator and inter-engine communication
- docs/client/ → Smart Client interface and user experience

🔧 Engine Documentation:
- Designer: Vehicle design with AI assistance (1-2 designs/tick)
- Economy: Market simulation and dynamic pricing
- Event: Breakthrough system and global events
- Factory: Factorio-like production with belts/assemblers
- Intelligence: Metrics collection (3.1GB adaptive) + reconnaissance
- Logistic: Supply chains and convoy management
- MacroEntity: Companies, diplomacy, administration (1000 pts/day)
- Map: Procedural generation (218+ elements) + chunk streaming
- Operation: Military strategy and adaptive AI generals
- War: Multi-chunk combat and persistent frontlines

📋 Each engine doc includes:
- Core responsibilities and system overview
- Key mechanics from relevant design documents
- Communication patterns with other engines
- Implementation notes and architecture details

🎯 Navigation optimized for:
- Engine developers (focused system details)
- System architects (coordination patterns)
- Game designers (mechanics integration)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-19 14:41:03 +08:00

3.6 KiB

Server Coordinator Documentation

Overview

The Server Coordinator orchestrates communication between the 10 autonomous engines and manages the Smart Client architecture.

Key Responsibilities:

  • Engine coordination and communication routing
  • Smart Client request/response management
  • Performance monitoring and load balancing
  • System-wide state synchronization

Architecture

Smart Client Pattern

From architecture-technique.md:

  • Request/Response Only: No streaming, stateless communication
  • Engine Autonomy: Engines operate independently between requests
  • Performance Target: 60fps with 1000+ AI companies
  • FOW Granularity: Chunk-level fog of war coordination

Engine Coordination

  • Inter-Engine Communication: Message routing between engines
  • State Synchronization: Coordinated updates across engine boundaries
  • Event Broadcasting: Global events distributed to all engines
  • Performance Monitoring: Engine load balancing and optimization

Core Systems

Communication Hub

class ServerCoordinator {
    // Engine management
    void registerEngine(EngineType type, std::shared_ptr<Engine> engine);
    void routeMessage(const Message& message);
    void broadcastEvent(const GlobalEvent& event);

    // Client management
    void handleClientRequest(const ClientRequest& request);
    ClientResponse processRequest(const ClientRequest& request);
    void updateClientFOW(int clientId, const FOWUpdate& update);

    // Performance monitoring
    void monitorEnginePerformance();
    void balanceEngineLoads();
    PerformanceMetrics getSystemMetrics() const;
};

Engine Communication Patterns

Economy ↔ Factory

  • Production cost calculations
  • Resource availability updates
  • Manufacturing order processing

War ↔ Operation

  • Battle result analysis
  • Strategic learning data
  • Tactical coordination

Intelligence ↔ All Engines

  • Metrics collection from every system
  • FOW updates and coordination
  • Performance analytics

Event → All Engines

  • Global event broadcasting
  • Breakthrough notifications
  • System-wide state changes

Client Request Processing

From architecture-technique.md:

  1. Request Validation: Ensure client permissions and data integrity
  2. Engine Routing: Direct requests to appropriate engines
  3. State Coordination: Manage cross-engine dependencies
  4. Response Assembly: Compile responses from multiple engines
  5. FOW Filtering: Apply visibility restrictions per client

Performance Requirements

  • 60fps Target: Maintain real-time performance
  • 1000+ Companies: Scale to massive multiplayer scenarios
  • Engine Autonomy: Minimize blocking between engines
  • Memory Efficiency: Optimize inter-engine communication

Key Integration Points

Fog of War Coordination

  • Intelligence-Engine: FOW state management
  • Map-Engine: Chunk visibility coordination
  • Client Filtering: Per-client visibility enforcement

Event System Integration

  • Event-Engine: Global event generation and scheduling
  • All Engines: Event consumption and response
  • Client Notification: Event broadcasting to relevant clients

Metrics and Analytics

  • Intelligence-Engine: System-wide metrics collection
  • Performance Monitoring: Real-time system health
  • Load Balancing: Dynamic resource allocation

Implementation Notes

  • Smart Client pattern eliminates streaming complexity
  • Engine autonomy maximizes parallel processing
  • FOW at chunk granularity optimizes performance
  • Message routing minimizes engine coupling