diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf105ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +# Compiled Object files +*.o +*.obj +*.lo +*.slo + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.a +*.lib +*.lai +*.la + +# Executables +*.exe +*.out +*.app + +# Build directories +build/ +cmake-build-*/ +target/ +bin/ +obj/ +Debug/ +Release/ +x64/ +x86/ + +# IDE files +.vscode/ +.vs/ +*.vcxproj.user +*.suo +*.user +*.userosscache +*.sln.docstates +.idea/ +*.cbp +*.depend +*.layout + +# CMake +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +Makefile +*.cmake +!CMakeLists.txt + +# Visual Studio +*.VC.db +*.VC.opendb +*.VC.VC.opendb + +# Code::Blocks +*.cbp + +# Temporary files +*.tmp +*.temp +*.log +*.cache + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +*~ + +# Dependencies +node_modules/ +*.lock + +# Config files (may contain sensitive data) +config/*.json +!config/*.example.json +*.env +*.local + +# Database files +*.db +*.sqlite +*.sqlite3 + +# Logs +logs/ +*.log + +# Package managers +*.tar.gz +*.zip +*.rar + +# Game data +saves/ +screenshots/ +replays/ + +# Redis dumps +dump.rdb \ No newline at end of file diff --git a/client/README.md b/client/README.md index 0765600..8189ee9 100644 --- a/client/README.md +++ b/client/README.md @@ -1,9 +1,37 @@ -# Smart Client +# C++ Smart Client -Smart client application for Warfactory with request/response pattern. +Client C++ natif pour Warfactory avec performance optimale et interface complète. -## Features -- Multi-scale map rendering -- Vehicle design interface -- Real-time factory management -- FOW at chunk granularity \ No newline at end of file +## Architecture +- **Request/Response**: Communication optimisée avec game orchestrator +- **Multi-scale Rendering**: 4 échelles avec transitions fluides (OpenGL) +- **FOW Granularity**: Par chunk (ultra-léger, ~1 bit par chunk) +- **Performance**: 60fps natif, chunks on-demand, optimisation mémoire + +## Core Features +- **Vehicle Design Interface**: Pick/place + A/E rotation + R snap toggle + templates +- **Factory Management**: Factorio-like avec belts, assemblers, inserters +- **Map Navigation**: Zoom discret, navigation node-based/libre +- **Real-time Combat**: Auto-battler avec oversight joueur +- **Multi-window Support**: Interface modulaire pour plusieurs écrans + +## Technical Stack +- **Rendering**: OpenGL pour performance 2D optimale +- **GUI Framework**: ImGui ou custom pour interfaces game-specific +- **Networking**: REST/HTTP client optimisé C++ +- **Audio**: 3D audio pour immersion combat/factory +- **Platform**: Cross-platform (Windows, Linux, Mac) + +## UI Modules +- **Map Viewer**: Multi-scale avec streaming chunks intelligent +- **Vehicle Designer**: Grille interactive + composants + contraintes réalistes +- **Factory Planner**: Belts + production chains + optimisation +- **Combat Interface**: Overview tactical + contrôles d'oversight +- **Intelligence Dashboard**: Métriques temps réel + reconnaissance +- **Diplomacy Panel**: Relations + administration points + négociations + +## Performance Targets +- **60fps constant** même avec 1000+ unités visibles +- **Memory efficient**: Chunks déchargés automatiquement +- **Network optimized**: Requests groupés, cache intelligent +- **Responsive UI**: <16ms latency pour toutes interactions \ No newline at end of file diff --git a/engines/Event-Engine/include/event-engine/EventEngine.h b/engines/Event-Engine/include/event-engine/EventEngine.h new file mode 100644 index 0000000..dae0b15 --- /dev/null +++ b/engines/Event-Engine/include/event-engine/EventEngine.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include +#include + +namespace Warfactory { +namespace Event { + +class GameEvent; +class BreakthroughSystem; +class EventQueue; + +/** + * Autonomous Event Engine + * Handles breakthrough system and global events + */ +class EventEngine { +public: + EventEngine(); + ~EventEngine(); + + bool initialize(); + void run(); + void shutdown(); + + // Event management + void scheduleEvent(std::unique_ptr event, double delaySeconds); + void triggerImmediateEvent(std::unique_ptr event); + + // Breakthrough system (event-driven with scrap analysis) + void analyzeScrapForBreakthrough(const std::string& scrapData); + void triggerBreakthrough(const std::string& technologyDomain); + + // Global events (geopolitical, natural disasters, etc.) + void generateRandomEvent(); + void processScheduledEvents(); + +private: + void engineLoop(); + void updateEventQueue(); + void dispatchEvents(); + + std::unique_ptr eventQueue_; + std::unique_ptr breakthroughSystem_; + std::thread engineThread_; + bool running_; + + void sendEvents(); + void receiveEventTriggers(); +}; + +} // namespace Event +} // namespace Warfactory \ No newline at end of file diff --git a/engines/Event-Engine/src/engine/main.cpp b/engines/Event-Engine/src/engine/main.cpp new file mode 100644 index 0000000..22d1c34 --- /dev/null +++ b/engines/Event-Engine/src/engine/main.cpp @@ -0,0 +1,25 @@ +#include +#include "event-engine/Event-EngineEngine.h" + +using namespace Warfactory::Event; + +int main(int argc, char* argv[]) { + std::cout << "Starting Event-Engine..." << std::endl; + + auto engine = std::make_unique(); + + if (!engine->initialize()) { + std::cerr << "Failed to initialize Event-Engine" << std::endl; + return 1; + } + + std::cout << "Event-Engine initialized successfully" << std::endl; + + // Run the autonomous engine + engine->run(); + + engine->shutdown(); + std::cout << "Event-Engine shutdown complete" << std::endl; + + return 0; +} diff --git a/engines/Factory-Engine/include/factory/FactoryEngine.h b/engines/Factory-Engine/include/factory/FactoryEngine.h new file mode 100644 index 0000000..bee7f14 --- /dev/null +++ b/engines/Factory-Engine/include/factory/FactoryEngine.h @@ -0,0 +1,57 @@ +#pragma once + +#include +#include +#include + +namespace Warfactory { +namespace Factory { + +class ProductionLine; +class Belt; +class Assembler; + +/** + * Autonomous Factory Engine + * Handles Factorio-like production simulation + */ +class FactoryEngine { +public: + FactoryEngine(); + ~FactoryEngine(); + + // Engine lifecycle + bool initialize(); + void run(); + void shutdown(); + + // Factory management + void addProductionLine(std::unique_ptr line); + void removeProductionLine(int lineId); + + // Production control + void startProduction(); + void stopProduction(); + void pauseProduction(); + + // Performance monitoring + double getTickRate() const { return tickRate_; } + size_t getActiveLines() const { return productionLines_.size(); } + +private: + void engineLoop(); + void updateProduction(); + void processInputOutput(); + + std::vector> productionLines_; + std::thread engineThread_; + bool running_; + double tickRate_; + + // Communication with other engines + void sendProductionData(); + void receiveOrders(); +}; + +} // namespace Factory +} // namespace Warfactory \ No newline at end of file diff --git a/engines/Factory-Engine/src/engine/main.cpp b/engines/Factory-Engine/src/engine/main.cpp new file mode 100644 index 0000000..e3028a7 --- /dev/null +++ b/engines/Factory-Engine/src/engine/main.cpp @@ -0,0 +1,25 @@ +#include +#include "factory/FactoryEngine.h" + +using namespace Warfactory::Factory; + +int main(int argc, char* argv[]) { + std::cout << "Starting Factory Engine..." << std::endl; + + auto engine = std::make_unique(); + + if (!engine->initialize()) { + std::cerr << "Failed to initialize Factory Engine" << std::endl; + return 1; + } + + std::cout << "Factory Engine initialized successfully" << std::endl; + + // Run the autonomous engine + engine->run(); + + engine->shutdown(); + std::cout << "Factory Engine shutdown complete" << std::endl; + + return 0; +} \ No newline at end of file diff --git a/engines/Logistic-Engine/include/logistic-engine/LogisticEngine.h b/engines/Logistic-Engine/include/logistic-engine/LogisticEngine.h new file mode 100644 index 0000000..482415c --- /dev/null +++ b/engines/Logistic-Engine/include/logistic-engine/LogisticEngine.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include +#include + +namespace Warfactory { +namespace Logistic { + +class Convoy; +class Route; +class SupplyChain; + +/** + * Autonomous Logistic Engine + * Handles transport and supply chains + */ +class LogisticEngine { +public: + LogisticEngine(); + ~LogisticEngine(); + + bool initialize(); + void run(); + void shutdown(); + + // Supply chain management + void createSupplyChain(const std::string& chainId, const std::vector& sites); + void updateRoute(const std::string& routeId, const std::vector>& waypoints); + + // Convoy management + void dispatchConvoy(const std::string& convoyId, const std::string& routeId); + void trackConvoyProgress(const std::string& convoyId); + + // Infrastructure (routes visible on map, attackable) + void markInfrastructureVulnerable(const std::string& routeId, bool vulnerable); + bool isRouteSecure(const std::string& routeId) const; + +private: + void engineLoop(); + void updateConvoys(); + void optimizeRoutes(); + + std::unordered_map> supplyChains_; + std::unordered_map> routes_; + std::unordered_map> convoys_; + std::thread engineThread_; + bool running_; + + void sendLogisticData(); + void receiveTransportRequests(); +}; + +} // namespace Logistic +} // namespace Warfactory \ No newline at end of file diff --git a/engines/Logistic-Engine/src/engine/main.cpp b/engines/Logistic-Engine/src/engine/main.cpp new file mode 100644 index 0000000..8568404 --- /dev/null +++ b/engines/Logistic-Engine/src/engine/main.cpp @@ -0,0 +1,25 @@ +#include +#include "logistic-engine/Logistic-EngineEngine.h" + +using namespace Warfactory::Logistic; + +int main(int argc, char* argv[]) { + std::cout << "Starting Logistic-Engine..." << std::endl; + + auto engine = std::make_unique(); + + if (!engine->initialize()) { + std::cerr << "Failed to initialize Logistic-Engine" << std::endl; + return 1; + } + + std::cout << "Logistic-Engine initialized successfully" << std::endl; + + // Run the autonomous engine + engine->run(); + + engine->shutdown(); + std::cout << "Logistic-Engine shutdown complete" << std::endl; + + return 0; +} diff --git a/engines/Operation-Engine/include/operation-engine/OperationEngine.h b/engines/Operation-Engine/include/operation-engine/OperationEngine.h new file mode 100644 index 0000000..249de10 --- /dev/null +++ b/engines/Operation-Engine/include/operation-engine/OperationEngine.h @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include + +namespace Warfactory { +namespace Operation { + +class AIGeneral; +class StrategicPlanner; +class DoctrineSystem; + +/** + * Autonomous Operation Engine + * Handles military strategy and adaptive AI generals + */ +class OperationEngine { +public: + OperationEngine(); + ~OperationEngine(); + + bool initialize(); + void run(); + void shutdown(); + + // Strategic planning and AI generals with ML + void createOperation(const std::string& operationId, const std::string& type); + void assignGeneral(const std::string& operationId, std::unique_ptr general); + void adaptBehaviorFromResults(const std::string& generalId, bool success); + + // Doctrine evolution (learning from successes/failures) + void updateDoctrine(const std::string& companyId, const std::string& lessons); + void analyzeBattleReports(const std::vector& reports); + +private: + void engineLoop(); + void processStrategicDecisions(); + void adaptAIBehavior(); // ML-based adaptation + + std::vector> generals_; + std::unique_ptr planner_; + std::unique_ptr doctrines_; + std::thread engineThread_; + bool running_; + + void sendOrders(); + void receiveBattleReports(); +}; + +} // namespace Operation +} // namespace Warfactory \ No newline at end of file diff --git a/engines/Operation-Engine/src/engine/main.cpp b/engines/Operation-Engine/src/engine/main.cpp new file mode 100644 index 0000000..9005a2b --- /dev/null +++ b/engines/Operation-Engine/src/engine/main.cpp @@ -0,0 +1,25 @@ +#include +#include "operation-engine/Operation-EngineEngine.h" + +using namespace Warfactory::Operation; + +int main(int argc, char* argv[]) { + std::cout << "Starting Operation-Engine..." << std::endl; + + auto engine = std::make_unique(); + + if (!engine->initialize()) { + std::cerr << "Failed to initialize Operation-Engine" << std::endl; + return 1; + } + + std::cout << "Operation-Engine initialized successfully" << std::endl; + + // Run the autonomous engine + engine->run(); + + engine->shutdown(); + std::cout << "Operation-Engine shutdown complete" << std::endl; + + return 0; +} diff --git a/server/README.md b/server/README.md new file mode 100644 index 0000000..7865117 --- /dev/null +++ b/server/README.md @@ -0,0 +1,41 @@ +# Game Orchestrator + +Serveur central orchestrant les 10 engines autonomes et gérant les clients. + +## Architecture +- **Engine Coordination**: Orchestration des 10 engines autonomes +- **Client Management**: REST API pour smart clients HTML +- **Redis Coordination**: Communication inter-engines via Redis +- **Performance**: 60fps tick global, engines autonomes + +## Responsabilités +- **API Gateway**: Interface REST pour clients HTML +- **Engine Lifecycle**: Start/stop/restart engines selon besoins +- **Session Management**: Gestion sessions joueurs multiples +- **Data Coordination**: Synchronisation état entre engines + +## Engine Communication +- **Factory Engine**: Production data, factory state +- **Logistic Engine**: Transport routes, convoys +- **Economy Engine**: Market prices, supply/demand +- **Designer Engine**: Vehicle designs, blueprints +- **MacroEntity Engine**: Company state, diplomacy +- **Map Engine**: Terrain data, chunks, FOW +- **War Engine**: Combat results, unit positions +- **Operation Engine**: Strategic orders, AI decisions +- **Intelligence Engine**: Metrics, reconnaissance data +- **Event Engine**: Global events, breakthroughs + +## API Endpoints +- `/api/map/*` - Map data, chunks, navigation +- `/api/factory/*` - Production, factory management +- `/api/vehicle/*` - Design interface, blueprints +- `/api/combat/*` - Combat oversight, orders +- `/api/intel/*` - Reconnaissance, metrics +- `/api/diplomacy/*` - Relations, administration + +## Technical Stack +- **Backend**: C++/Node.js pour performance +- **Database**: Redis pour coordination, PostgreSQL pour persistence +- **Communication**: REST API, WebSocket pour real-time updates +- **Scaling**: Horizontal scaling par engine type \ No newline at end of file diff --git a/shared/README.md b/shared/README.md new file mode 100644 index 0000000..9b51a57 --- /dev/null +++ b/shared/README.md @@ -0,0 +1,52 @@ +# Shared Types & Interfaces + +Types de données partagés entre engines, client et orchestrator. + +## Data Structures + +### Core Game Types +- **TilePosition**: Coordonnées tiles (x, y) 1m×1m +- **ChunkId**: Identifier chunks 64×64 tiles +- **CompanyId**: Identifier companies/players +- **VehicleDesign**: Structure design véhicules avec composants + +### Map System +- **TerrainType**: Types terrain (65k variants possibles) +- **ResourcePatch**: Patches ressources grid-aligned +- **FOWState**: État fog of war par chunk +- **BiomeData**: Données biomes et features géologiques + +### Military System +- **ComponentGrid**: Grille composants véhicules +- **CombatUnit**: État unités en combat +- **Doctrine**: Doctrines militaires par company +- **BattleReport**: Rapports combat pour intelligence + +### Economy & Logistics +- **MarketPrice**: Prix marchés par produit/région +- **SupplyChain**: Chaînes logistiques inter-sites +- **ProductionQueue**: Files production usines +- **TradeRoute**: Routes commerciales et convois + +### Administration & Diplomacy +- **AdminPoints**: Pool points administration quotidiens +- **DiplomaticRelation**: Relations entre companies/états +- **CompanyFeature**: Features companies (2-4 par company) +- **GeopoliticalEvent**: Événements géopolitiques majeurs + +## Communication Protocols + +### Engine-to-Engine +- **Redis Message Format**: Structure messages inter-engines +- **Event Bus**: Système événements globaux +- **State Sync**: Synchronisation état cross-engine + +### Client-Server API +- **REST Endpoints**: Spécifications API REST +- **Request/Response**: Formats données client-serveur +- **Error Handling**: Codes erreur standardisés + +## Constants & Configuration +- **Performance Targets**: 60fps, tick rates, memory limits +- **Game Balance**: Valeurs équilibrage (coûts, durées, etc.) +- **Network Config**: Timeouts, retry policies \ No newline at end of file