Skip to content

binaryBard97/parallel-cellular-auto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a Rust implementation of a simple elementary cellular automaton (ECA) simulation that follows the rules specified by a given rule set.

Elementary Cellular Automaton

Elementary Cellular Automaton is a one-dimensional array of cells, each having two possible states (usually represented as 0 or 1). The state of each cell evolves over discrete time steps based on a set of rules, typically defined by a binary number.

Implementation Overview

Dependencies

The code uses the following dependencies from the standard library:

use std::io::Write;
use std::sync::mpsc;
use std::sync::Arc;
use std::thread;

Function Signature

pub fn run_eca<W>(
    threads: usize,
    rule: [bool; 8],
    size: usize,
    steps: usize,
    indices: Vec<usize>,
    write: Option<W>,
) -> ((usize, usize), (usize, usize), usize)
where
    W: Write + Send + 'static,
{
    // Function implementation...
}

Parameters

  • threads: Number of threads to use for parallel processing.
  • rule: The rule set for the elementary cellular automaton.
  • size: The size of the cellular automaton array.
  • steps: The number of steps to simulate.
  • indices: Initial indices of active cells.
  • write: Optional output stream for visualizing the simulation.

Parallelization

The simulation is parallelized using multiple threads, each responsible for a portion of the cellular automaton.

Communication Channels

The code uses mpsc channels for communication between threads. Channels are created for sending and receiving data between left and right neighbors, as well as for visualizing the state if required.

Simulation Loop

The main simulation loop iterates over the specified number of steps. In each step:

  • The current state is communicated between neighboring threads.
  • The rule set is applied to determine the next state.
  • Popcount (number of active cells) is sent to the main thread for analysis.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages