Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ca_block_rule.H File Reference

Block-based local rules for Aleph::CA (Phase 13). More...

#include <array>
#include <concepts>
#include <cstddef>
#include <type_traits>
#include <utility>
Include dependency graph for tpl_ca_block_rule.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::CA::Critters_Rule
 Critters reversible CA block rule. More...
 
class  Aleph::CA::BBM_Rule
 Fredkin–Toffoli Billiard Ball Machine block rule. More...
 
class  Aleph::CA::TM_Gas_Rule
 Toffoli–Margolus (TM) lattice-gas block rule. More...
 
class  Aleph::CA::Cell_Rule_As_Block_Rule< Cell_Rule >
 Adapt a regular cell rule (with empty neighborhood) to a block rule. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 
namespace  Aleph::CA::ca_block_rule_detail
 

Concepts

concept  Aleph::CA::Block_Rule_2x2
 A rule that maps a 2×2 block to a 2×2 block.
 

Typedefs

template<typename State >
using Aleph::CA::Block_2x2 = std::array< State, 4 >
 Fixed-size 2×2 block of cell values used by Margolus rules.
 

Functions

template<typename State >
constexpr State Aleph::CA::ca_block_rule_detail::invert (const State &s) noexcept
 Toggle a cell value between its zero and a non-zero counterpart.
 
template<typename State >
constexpr std::size_t Aleph::CA::ca_block_rule_detail::popcount (const Block_2x2< State > &b) noexcept
 Population count of a 2×2 block: number of non-zero cells.
 

Detailed Description

Block-based local rules for Aleph::CA (Phase 13).

Where a RuleLike rule consumes (state, neighbours) and returns one cell value, a block rule consumes a fixed-size block of cell values and returns the new block in one shot. Block rules are the natural fit for the Margolus update (tpl_ca_update_scheme.H): the partition decides which 2×2 cells form the active block, and the rule rewrites those four cells atomically.

The bundled rules cover the canonical reversible automata:

  • Critters_Rule — invert population if popcount != 2, then rotate the block 180°. Reversible because both invert and rotate-180 are involutions.
  • BBM_Rule — Fredkin & Toffoli's Billiard Ball Machine logic.
  • TM_Gas_Rule — Toffoli–Margolus lattice gas (variant of BBM that conserves particles and momentum).
  • Cell_Rule_As_Block_Rule<R> — adaptor that wraps a regular cell rule (whose neighbourhood is empty) as a block rule.

Convention for the 2×2 block array:

index 0 = NW (top-left)     index 1 = NE (top-right)
index 2 = SW (bottom-left)  index 3 = SE (bottom-right)
Author
Leandro Rabindranath Leon

Definition in file tpl_ca_block_rule.H.