Crates.io | gpca |
lib.rs | gpca |
version | 0.2.1 |
source | src |
created_at | 2024-10-18 22:19:21.965261 |
updated_at | 2024-10-25 19:24:53.110055 |
description | Rust implementation of the 'Async Hyper-Graph Cellular Automata' computational model. |
homepage | |
repository | |
max_upload_size | |
id | 1414915 |
size | 155,806 |
General-Purpose Cellular Automata (GPCA) is a Rust implementation of the computational model known as Async Hyper-Graph Cellular Automata. This library provides a framework for simulating and experimenting with complex systems through autómata cellular dynamics, utilizing parallel computing and GPU acceleration for enhanced performance.
wgpu
for GPU-accelerated computations and simulations.rayon
for parallel computation, ensuring efficient performance on multi-core systems.cargo run --example latest --features=rand
To use GPCA in your Rust project, add the following dependency to your Cargo.toml
:
[dependencies]
gpca = { version = "0.1.0"}
Below is an example that demonstrates how to simulate a 2D cyclic cellular automaton with 8 states:
use gpca::{
dynamics::implementations::cyclic::CyclicAutomaton,
spaces::implementations::basic::{DiscreteState, HyperGraphHeap},
system::{dynamical_system::DynamicalSystem, utils::save_space_as_image},
third::wgpu::create_gpu_device,
};
use kdam::tqdm;
#[tokio::main]
async fn main() {
const W: u32 = 512;
const H: u32 = 512;
const STATES: u32 = 4;
const THRESH: u32 = 2;
let _device = create_gpu_device();
let mem = DiscreteState::filled_vector(W * H, STATES);
let space = HyperGraphHeap::new_grid(&mem, W, H, ());
let dynamic = CyclicAutomaton::new(STATES, THRESH);
let mut system = DynamicalSystem::new(Box::new(space), Box::new(dynamic));
for _ in tqdm!(0..500) {
system.compute_sync_wgpu(&_device);
}
save_space_as_image(&system, colorous::PLASMA);
}
Contributions are welcome! Feel free to open an issue or submit a pull request with new features, bug fixes, or improvements.
This project is licensed under the MIT License.