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
39 public:
41
49 explicit OverloadAndRemoveStrategy(gsl::not_null<const UserDiagnostics *> diag) : diag_{diag} {}
50
62 std::size_t max_attempts,
63 std::uint64_t seed,
64 ShuffleStrategy shuffle_strategy,
65 const UserDiagnostics *diag = nullptr)
66 : use_preset_matrix_{false}, max_attempts_{max_attempts}, seed_{seed}, shuffle_strategy_{shuffle_strategy},
67 diag_{diag}
68 {
69 }
70
80 [[nodiscard]] ChainableResult<PackingOutput> pack(const PackingInput &input) const override;
81
85 [[nodiscard]] std::string name() const override
86 {
87 return "Overload-And-Remove";
88 }
89
90 private:
91 bool use_preset_matrix_ = true;
92 std::size_t max_attempts_ = 20;
93 std::uint64_t seed_ = 42;
95 const UserDiagnostics *diag_ = nullptr;
96
108 [[nodiscard]] ChainableResult<PackingOutput> run_multi_start(
109 const PackingInput &input,
110 ShuffleStrategy shuffle_strategy,
111 std::size_t max_attempts,
112 std::uint64_t seed) const;
113
120 [[nodiscard]] ChainableResult<PackingOutput> try_pack(
121 const PackingInput &input, ShuffleStrategy shuffle_strategy, std::optional<std::uint64_t> shuffle_seed) const;
122};
123
124} // 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.