How tomster12/factorio-blueprints works
Project Type & Purpose
• This is a standalone C++ command‐line tool (“FactorioBlueprints”) that generates optimal layout blueprints for the game Factorio.
• It combines a Simulated Annealing–based Optimization Engine (for assembler/inserter placement) with a CBS + A*–based Pathfinding Engine (for multi-agent conveyor routing).
File‐Structure Analysis
• Top level: a Visual Studio solution (FactorioBlueprints.sln) and single project directory.
• Core modules in FactorioBlueprints/:
• main.cpp → CLI entry point, argument parsing
• ProblemSolver.* → SimulatedAnnealingCore
• PlacementState.*→ in‐memory representation of the current blueprint layout
• PlacementPathfinder.*→ ConveyorRoutingEngine (CBS + A* pathfinder)
• global.*, log.h, macros.h, types.h, ls.h, pf.h → configuration, logging, shared types, macro utilities
README Insights
• Uses Simulated Annealing to optimize assembler & inserter placement.
• Uses Conflict‐Based Search + A* for conveyor belt pathfinding.
• Core flow: load blueprint parameters → run optimization loop → output best blueprint.
1. CLI Frontend
– Parses user inputs (blueprint specs, iteration count, output path)
2. Input/Output Module
– Blueprint Loader/Parser (JSON or text format)
– Blueprint Serializer (final optimized blueprint export)
3. Optimization Engine (SimulatedAnnealingCore)
– “AssemblerInserterPlacementEngine”
– Manages temperature schedule, neighbor generation, acceptance criteria
4. Placement State
– Current layout model (factories, inserters, belts)
– Provides interface to evaluate and apply moves
5. Pathfinding Engine (ConveyorRoutingEngine)
– CBS Coordinator
– A* Sub‐searchers for individual conveyor agents
6. Support Services
– GlobalConfig (global constants, parameters)
– Logging Service (log.h) for metrics, debug output
– Shared Types & Macros (types.h, macros.h, ls.h, pf.h)
b. Relationships & Data Flow
• CLI Frontend → Input Parser: load blueprint spec → Initial PlacementState
• SimulatedAnnealingCore
↔ PlacementState: generate neighbor states (move an assembler/inserter)
↔ PathfindingEngine: whenever a change affects belts, recompute routes via CBS + A*
→ Logging Service: record energy/cost, temperature, acceptance decisions
• On termination: PlacementState → Output Serializer → final blueprint file
c. Architectural Patterns & Principles
• Modular separation: distinct layers for CLI, IO, optimization logic, pathfinding, and utilities
• Pipeline style: Input → Optimize (with inner loop) → Output
• Algorithmic kernels isolated into ProblemSolver and PlacementPathfinder
d. Key Technologies & Libraries
• C++17 (or later), Visual Studio project
• Custom Simulated Annealing implementation
• Custom multi-agent CBS + A* pathfinder
• Green for front‐end/Input/Output
• Blue for Optimization Engine
• Orange for Pathfinding Engine
• Gray for Support Services (Config, Logging)