Porytiles
Loading...
Searching...
No Matches
backtracking_strategy.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <limits>
5#include <string>
6
7#include "gsl/pointers"
8
13
14namespace porytiles {
15
51 public:
53
63 explicit BacktrackingStrategy(gsl::not_null<const UserDiagnostics *> diag) : diag_{diag} {}
64
81 std::size_t node_cutoff,
82 std::size_t best_branches,
83 bool smart_prune,
84 const UserDiagnostics *diag = nullptr)
85 : use_preset_matrix_{false}, algorithm_{algorithm}, node_cutoff_{node_cutoff}, best_branches_{best_branches},
86 smart_prune_{smart_prune}, diag_{diag}
87 {
88 }
89
102 [[nodiscard]] ChainableResult<PackingOutput> pack(const PackingInput &input) const override;
103
109 [[nodiscard]] std::string name() const override
110 {
111 return "Backtracking";
112 }
113
114 private:
115 bool use_preset_matrix_ = true;
117 std::size_t node_cutoff_ = 1'000'000;
118 std::size_t best_branches_ = std::numeric_limits<std::size_t>::max();
119 bool smart_prune_ = true;
120 const UserDiagnostics *diag_ = nullptr;
121};
122
123} // namespace porytiles
std::size_t node_cutoff
std::size_t best_branches
SearchAlgorithm algorithm
bool smart_prune
Packing strategy that assigns tiles to palettes using BFS/DFS backtracking with a fallback matrix.
std::string name() const override
Returns the name of this strategy.
BacktrackingStrategy(gsl::not_null< const UserDiagnostics * > diag)
Constructs in preset matrix mode with diagnostics support.
BacktrackingStrategy(SearchAlgorithm algorithm, std::size_t node_cutoff, std::size_t best_branches, bool smart_prune, const UserDiagnostics *diag=nullptr)
Constructs with explicit search parameters for single-configuration mode.
ChainableResult< PackingOutput > pack(const PackingInput &input) const override
Packs tiles into palettes using BFS/DFS backtracking search.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Abstract interface for palette packing algorithms.
Abstract class for structured error reporting and diagnostic output.
SearchAlgorithm
Search algorithm used by BacktrackingStrategy.
@ dfs
Depth-first search with in-place mutation and undo.
Input data aggregate for the low-level palette packing algorithm.