Skip to main content

clcell

clcell is an OpenCL-accelerated cellular automata simulator for Python 3.

Features

  • OpenCL-based hardware acceleration
  • Custom rulesets via clcell.RuleSet
  • Parallel simulations via clcell.CASimulator.batch_simulate

Limitations

  • Only binary cell states
  • No support for infinite grids
  • Grid boundary cells must be unpopulated

Installation

Regardless of the installation method you choose, you will need OpenCL drivers for your hardware.

Using pip

$ pip install --user clcell

Building from Source

Requirements:

Clone this repository:

$ git clone https://github.com/Foxbud/clcell.git

Enter the project directory:

$ cd clcell

Build and install this package:

$ make install

Usage

import numpy as np
import clcell

# Instantiate a simulator using Conway's Game of Life as the ruleset.
sim = clcell.CASimulator(clcell.LIFE)

# Create a randomized game state to use as a seed.
seed_state = np.random.randint(0, 2, (1023, 1023), dtype=np.int8)
# Pad state with zeros (required for now).
seed_state = np.pad(seed_state, 1, constant_values=0)

# Simulate 10,000 generations based on that seed.
final_state = sim.simulate(10000, seed_state)

# Create a batch of 1,000 randomized, padded game states to use as seeds.
seed_states = np.array([
  np.pad(
    np.random.randint(0, 2, (127, 127), dtype=np.int8),
    1,
    constant_values=0
  )
  for num
  in range(1000)
])

# Simulate 1,000 generations based on each of those seeds.
final_states = sim.batch_simulate(1000, seed_states)

Changelog

v1.0.1

  • Simplified how the device code checks for boundary cells.
  • Refactored device code to use grids of 8-bit cells as opposed to 32-bit.
  • Fixed incorrectly placed size annotations in one device function.

v1.0.0

  • Initial release.

Metadata

Release files for clcell 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for clcell 1.0.1
File Interpreter ABI Platform
clcell-1.0.1-py3-none-any.whl Python 3 none any Details

Release files / clcell-1.0.1-py3-none-any.whl

Download URL clcell-1.0.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5ee1c48430226f566213968dc77c7e563d8a248cba82478e2d92ed7b2d74694
BLAKE2b-256 checksum
How to use checksums
8290e1d6301075a812ae2019e95dae85f585883d900313a8703dc9a155947080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page