Porytiles
Loading...
Searching...
No Matches
overload_and_remove_strategy.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <optional>
6#include <string>
7
8#include "gsl/pointers"
9
14
15namespace porytiles {
16
41 public:
43
53 explicit OverloadAndRemoveStrategy(gsl::not_null<const UserDiagnostics *> diag) : diag_{diag} {}
54
68 std::size_t max_attempts,
69 std::uint64_t seed,
70 ShuffleStrategy shuffle_strategy,
71 const UserDiagnostics *diag = nullptr)
72 : use_preset_matrix_{false}, max_attempts_{max_attempts}, seed_{seed}, shuffle_strategy_{shuffle_strategy},
73 diag_{diag}
74 {
75 }
76
88 [[nodiscard]] ChainableResult<PackingOutput> pack(const PackingInput &input) const override;
89
95 [[nodiscard]] std::string name() const override
96 {
97 return "Overload-And-Remove";
98 }
99
100 private:
101 bool use_preset_matrix_ = true;
102 std::size_t max_attempts_ = 20;
103 std::uint64_t seed_ = 42;
105 const UserDiagnostics *diag_ = nullptr;
106
120 [[nodiscard]] ChainableResult<PackingOutput> run_multi_start(
121 const PackingInput &input,
122 ShuffleStrategy shuffle_strategy,
123 std::size_t max_attempts,
124 std::uint64_t seed) const;
125
134 [[nodiscard]] ChainableResult<PackingOutput> try_pack(
135 const PackingInput &input, ShuffleStrategy shuffle_strategy, std::optional<std::uint64_t> shuffle_seed) const;
136};
137
138} // namespace porytiles
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Packing strategy that assigns tiles to palettes using overload-and-remove with multi-start.
OverloadAndRemoveStrategy(std::size_t max_attempts, std::uint64_t seed, ShuffleStrategy shuffle_strategy, const UserDiagnostics *diag=nullptr)
Constructs with explicit parameters for single-configuration mode.
ChainableResult< PackingOutput > pack(const PackingInput &input) const override
Packs tiles into palettes using the Overload-And-Remove algorithm with multi-start.
OverloadAndRemoveStrategy(gsl::not_null< const UserDiagnostics * > diag)
Constructs in preset matrix mode with diagnostics support.
std::string name() const override
Returns the name of this strategy.
Abstract interface for palette packing algorithms.
Abstract class for structured error reporting and diagnostic output.
ShuffleStrategy
Controls how tile orderings are generated during multi-start packing.
@ noisy_ffd
FFD first, then perturbed FFD orderings that preserve the large-first property.
Input data aggregate for the low-level palette packing algorithm.