11#ifndef CDT_PLUSPLUS_MOVE_TRACKER_HPP
12#define CDT_PLUSPLUS_MOVE_TRACKER_HPP
26namespace cdt::move_tracker
34 enum class [[nodiscard(
"This contains data!")]]
MoveType
67 template <
typename Enumeration>
68 requires std::is_enum_v<Enumeration>
69 [[nodiscard]]
constexpr auto as_integer(Enumeration
const value)
noexcept
70 -> std::underlying_type_t<Enumeration>
72 return static_cast<std::underlying_type_t<Enumeration>
>(value);
81 std::size_t
const move_choice)
noexcept -> std::optional<MoveType>
87 if (move_choice >= moves.size()) {
return std::nullopt; }
88 return moves[move_choice];
95 template <std::uniform_random_bit_generator Generator>
99 std::uniform_int_distribution<int> distribution{
101 auto const move_choice = distribution(generator);
110 using Container = std::array<Int_precision, NUMBER_OF_3D_MOVES>;
112 Container moves = {0};
119 [[nodiscard]]
auto moves_view() const noexcept {
return std::span(moves); }
126 [[nodiscard]]
auto operator[](gsl::index
const index) ->
auto&
127 {
return gsl::at(moves, index); }
134 [[nodiscard]]
auto operator[](gsl::index
const index)
const ->
auto const&
135 {
return gsl::at(moves, index); }
160 for (std::size_t i = 0; i < moves.size(); ++i)
162 moves[i] += rhs.moves[i];
171 [[nodiscard]]
auto total() const noexcept
173 return std::accumulate(moves.begin(), moves.end(),
Int_precision{0});
180 [[nodiscard]]
auto size() const noexcept {
return moves.size(); }
constexpr auto as_integer(Enumeration const value) noexcept -> std::underlying_type_t< Enumeration >
Convert enum to integer.
MoveType
The types of 3D ergodic moves.
@ TWO_THREE
Replace two tetrahedra with three.
@ SIX_TWO
Replace six tetrahedra with two.
@ THREE_TWO
Replace three tetrahedra with two.
@ FOUR_FOUR
Exchange a causal four-tetrahedron diamond.
@ TWO_SIX
Replace two tetrahedra with six.
constexpr auto format_as(MoveType const move) noexcept -> std::string_view
Enable direct formatting through fmt/spdlog.
auto generate_random_move_3(Generator &generator) -> MoveType
Generate a uniformly distributed 3D move from caller-owned RNG.
constexpr auto move_from_index(std::size_t const move_choice) noexcept -> std::optional< MoveType >
Convert an integer index to MoveType.
constexpr std::size_t NUMBER_OF_3D_MOVES
Number of supported Pachner move kinds in three dimensions.
Global integer and precision settings.
The data and methods to track ergodic moves.
auto four_four_moves() const
Read access to (4,4) moves.
auto size() const noexcept
Container size.
auto three_two_moves() const
Read access to (3,2) moves.
auto three_two_moves() -> auto &
Write access to (3,2) moves.
auto operator[](gsl::index const index) const -> auto const &
The [] operator for a read-only MoveTracker.
auto moves_view() const noexcept
Get a view of the moves.
auto two_three_moves() -> auto &
Write access to (2,3) moves.
auto operator[](gsl::index const index) -> auto &
The [] operator for MoveTracker.
auto six_two_moves() -> auto &
Write access to (6,2) moves.
auto two_three_moves() const
Read access to (2,3) moves.
auto operator[](MoveType const move) -> auto &
The [] operator for MoveTracker.
void reset()
Reset all moves counts to zero.
auto two_six_moves() const
Read access to (2,6) moves.
auto four_four_moves() -> auto &
Write access to (4,4) moves.
auto operator+=(MoveTracker const &rhs) -> MoveTracker &
The += operator for MoveTracker.
auto operator[](MoveType const move) const -> auto const &
The [] operator for a read-only MoveTracker.
auto total() const noexcept
Total moves.
auto two_six_moves() -> auto &
Write access to (2,6) moves.
auto six_two_moves() const
Read access to (6,2) moves.
std::int32_t Int_precision