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
49 public:
51
59 explicit BacktrackingStrategy(gsl::not_null<const UserDiagnostics *> diag) : diag_{diag} {}
60
75 std::size_t node_cutoff,
76 std::size_t best_branches,
77 bool smart_prune,
78 const UserDiagnostics *diag = nullptr)
79 : use_preset_matrix_{false}, algorithm_{algorithm}, node_cutoff_{node_cutoff}, best_branches_{best_branches},
80 smart_prune_{smart_prune}, diag_{diag}
81 {
82 }
83
94 [[nodiscard]] ChainableResult<PackingOutput> pack(const PackingInput &input) const override;
95
99 [[nodiscard]] std::string name() const override
100 {
101 return "Backtracking";
102 }
103
104 private:
105 bool use_preset_matrix_ = true;
107 std::size_t node_cutoff_ = 1'000'000;
108 std::size_t best_branches_ = std::numeric_limits<std::size_t>::max();
109 bool smart_prune_ = true;
110 const UserDiagnostics *diag_ = nullptr;
111};
112
113} // 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.