42# include <gtest/gtest.h>
96 std::set<std::pair<int, int>>
seen;
97 std::size_t calls = 0;
98 nh.for_each_offset({ 0, 0 }, [&](
const auto &
o)
104 seen.emplace(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
113 std::size_t calls = 0;
117 EXPECT_LE(std::max(std::abs((
int)
o[0]), std::abs((
int)
o[1])), 2);
131 std::set<std::pair<int, int>>
seen;
132 nh.for_each_offset({ 0, 0 }, [&](
const auto &
o) {
133 seen.emplace(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
144 std::size_t calls = 0;
147 const int s = std::abs((
int)
o[0]) + std::abs((
int)
o[1]);
162 std::set<std::pair<int, int>>
seen;
163 nh.for_each_offset({ 0, 0 }, [&](
const auto &
o) {
164 seen.emplace(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
186 nh.for_each_offset({ 0, 0 }, [&](
const auto &
o) {
187 seen_even.emplace(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
194 std::set<std::pair<int, int>>
seen_odd;
195 nh.for_each_offset({ 0, 1 }, [&](
const auto &
o) {
196 seen_odd.emplace(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
215 std::vector<std::pair<int, int>>
seen;
216 nh.for_each_offset({ 0, 0 }, [&](
const auto &
o) {
217 seen.emplace_back(
static_cast<int>(
o[0]),
static_cast<int>(
o[1]));
234 lat.set({ i, j },
static_cast<int>(i * 10 + j));
237 std::array<int, Moore<2, 1>::size_v> buf { };
239 std::span<int>(buf.data(), buf.size()));
245 for (
int v : buf)
total += v;
253 std::array<int, Moore<2, 1>::size_v> buf { };
255 std::span<int>(buf.data(), buf.size()));
260 for (
int v : buf)
if (v != 0) ++alive;
268 std::array<int, 2> buf { };
270 std::span<int>(buf.data(), buf.size())),
Common typedefs and tag types for the Cellular Automata module.
User-supplied list of offsets for arbitrary connectivity.
Six-neighbour hex pattern in axial coordinates over a 2D lattice.
static constexpr std::size_t size_v
Number of neighbours (always 6).
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
constexpr void for_each_offset(const Coord_Vec< N > ¢er, F &&f) const
Apply a functor to each offset in the neighborhood.
Three edge-neighbours over a 2D lattice with parity coupling.
static constexpr std::size_t size_v
Number of neighbours (always 3).
Von Neumann (L1) neighborhood of radius R in N dimensions.
constexpr void for_each_offset(const Coord_Vec< N > ¢er, F &&f) const
Apply a functor to each offset in the neighborhood.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
void gather_neighbors(const Nbh &nh, const L &lat, const typename L::coord_type ¢er, std::span< T > out)
Populate out[0..nh.size()) with neighbour values of center.
Coord_Vec< N > Offset_Vec
Default offset vector (aliases Coord_Vec).
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Out-of-range neighbours behave as if the lattice ended.
The lattice wraps around on every axis.
C++20 concepts for the Cellular Automata module.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).