13#ifndef INCLUDE_MOVE_ALWAYS_HPP_
14#define INCLUDE_MOVE_ALWAYS_HPP_
27 template <
typename ManifoldType>
28 requires(ManifoldType::dimension == 3)
31 using CommandResults = detail::MoveCommandResults<ManifoldType>;
32 using PassResult = detail::MovePassResult<ManifoldType, std::monostate>;
41 bool m_write_files{
true};
44 CommandResults m_command_results;
49 [[nodiscard]]
auto execute_pass(ManifoldType current,
50 std::monostate strategy_state,
54 for (
auto move_attempt =
Int_precision{0}; move_attempt < attempts;
60 auto command_results =
62 return {.manifold = std::move(command).result(),
63 .command_results = std::move(command_results),
64 .strategy_state = strategy_state};
67 static void print_results(CommandResults
const& results)
69 fmt::print(
"=== Move Results ===\n");
70 fmt::print(
"(2,3) moves: {} attempted = {} successful and {} failed.\n",
71 results.attempted.two_three_moves(),
72 results.succeeded.two_three_moves(),
73 results.failed.two_three_moves());
74 fmt::print(
"(3,2) moves: {} attempted = {} successful and {} failed.\n",
75 results.attempted.three_two_moves(),
76 results.succeeded.three_two_moves(),
77 results.failed.three_two_moves());
78 fmt::print(
"(2,6) moves: {} attempted = {} successful and {} failed.\n",
79 results.attempted.two_six_moves(),
80 results.succeeded.two_six_moves(),
81 results.failed.two_six_moves());
82 fmt::print(
"(6,2) moves: {} attempted = {} successful and {} failed.\n",
83 results.attempted.six_two_moves(),
84 results.succeeded.six_two_moves(),
85 results.failed.six_two_moves());
86 fmt::print(
"(4,4) moves: {} attempted = {} successful and {} failed.\n",
87 results.attempted.four_four_moves(),
88 results.succeeded.four_four_moves(),
89 results.failed.four_four_moves());
114 bool const write_files =
true)
128 bool const write_files =
true)
129 : m_cadence{detail::parse_move_run_cadence(t_number_of_passes,
130 t_checkpoint,
"MoveAlways")}
131 , m_random{std::move(random)}
132 , m_write_files{write_files}
136 [[nodiscard]]
auto passes() const noexcept {
return m_cadence.passes(); }
140 {
return m_cadence.checkpoint(); }
144 {
return m_checkpoint_events; }
147 [[nodiscard]]
auto seed() const noexcept {
return m_random.seed(); }
150 [[nodiscard]]
auto stream() const noexcept {
return m_random.stream(); }
153 [[nodiscard]]
auto writes_files() const noexcept {
return m_write_files; }
157 -> move_tracker::MoveTracker const&
158 {
return m_command_results.attempted; }
162 -> move_tracker::MoveTracker const&
163 {
return m_command_results.succeeded; }
166 [[nodiscard]]
auto failed() const noexcept
167 -> move_tracker::MoveTracker const&
168 {
return m_command_results.failed; }
180 [[nodiscard]]
auto operator()(ManifoldType
const& t_manifold)
187 t_manifold, CommandResults{}, std::monostate{}, 0, m_cadence,
188 detail::MoveRunIdentity{
189 .algorithm =
"Move Always", .seed =
seed(), .stream =
stream()},
191 [
this](ManifoldType current, std::monostate state,
193 return execute_pass(std::move(current), state, attempts);
195 [](ManifoldType
const&, CommandResults
const& results,
196 std::monostate
const&) { print_results(results); },
197 [
this](ManifoldType
const& current, CommandResults
const&,
202 m_command_results = std::move(result.command_results);
203 m_checkpoint_events = result.checkpoint_events;
204 return std::move(result.manifold);
Do ergodic moves using the Command pattern.
Shared value-oriented orchestration for ergodic-move strategies.
auto consume_command_results(Command &command) -> MoveCommandResults< ManifoldType >
Consume cumulative MoveCommand counters exactly once.
auto execute_move_run(ManifoldType initial, MoveCommandResults< ManifoldType > initial_command_results, StrategyState initial_strategy_state, Int_precision const completed_passes, MoveRunCadence const cadence, MoveRunIdentity const identity, bool const writes_files, ExecutePass execute_pass, Report report, Checkpoint checkpoint) -> MoveRunResult< ManifoldType, StrategyState >
Execute shared pass, accounting, checkpoint, and report cadence.
Template class for move algorithms (strategies) on manifolds.
auto generate_random_move_3(Generator &generator) -> MoveType
Generate a uniformly distributed 3D move from caller-owned RNG.
Run-owned random-number generation and reproducible stream splitting.
#define CDT_PRETTY_FUNCTION
Cross-platform spelling of the current function signature for diagnostics.
void write_file(std::filesystem::path const &filename, TriangulationType const &triangulation)
Write triangulation to file.
Queue and execute requested moves against a three-dimensional manifold while tracking attempted and s...
void execute(Generator &generator)
Execute all moves in the queue on the manifold.
void enqueue(move_tracker::MoveType const t_move)
Push a Pachner move onto the move queue.
Positive pass count and checkpoint interval for a move run.
MoveStrategy(Int_precision const t_number_of_passes, Int_precision const t_checkpoint)
Construct a MoveAlways run using a fresh entropy-backed stream.
auto passes() const noexcept
auto operator()(ManifoldType const &t_manifold) -> ManifoldType
Execute a fresh run while continuing the owned random stream.
void print_results() const
Display results of the latest completed invocation.
auto writes_files() const noexcept
auto checkpoint_events() const noexcept
auto attempted() const noexcept -> move_tracker::MoveTracker const &
MoveStrategy(Int_precision const t_number_of_passes, Int_precision const t_checkpoint, cdt::Random random, bool const write_files=true)
Construct a MoveAlways run from an owned PCG stream.
auto checkpoint() const noexcept
auto succeeded() const noexcept -> move_tracker::MoveTracker const &
MoveStrategy(Int_precision const t_number_of_passes, Int_precision const t_checkpoint, cdt::RandomSeed const seed, bool const write_files=true)
Construct a replayable MoveAlways run from an explicit seed.
auto stream() const noexcept
MoveStrategy()=default
Default ctor.
auto failed() const noexcept -> move_tracker::MoveTracker const &
auto seed() const noexcept
A run-owned PCG engine with a recorded seed and stream identifier.
Root entropy value used to reproduce a random run.
clang-15 does not support std::format
std::int32_t Int_precision
MoveStrategy< MoveStrategyKind::MOVE_ALWAYS, manifolds::Manifold_3 > MoveAlways_3
Always-accept-applicable move strategy for the supported 3D manifold.