Giter Site home page Giter Site logo

ncurses_cellular_automaton's Introduction

ncurses_Cellular_Automaton

[OPEN_SOURCE_HEART_BADGE] [BSD_2_CLAUSE_LICENSE_BADGE]

An elementary cellular automaton with a text-based user interface for your terminal.

Motivation

This project is my attempt at making "Rule 30", a cellular automaton introduced by Stephen Wolfram in 1983, somewhat explorable for the interested. The ncurses-Cellular-Automaton lets you quickly try out all of the 256 rules on different starting conditions and get a feel for how an elementary CA works in real-time, on the command line.

I suggest reading Wolfram's (free) book A New Kind of Science for an introduction to the mechanics behind rule 30 and other cellular automata.

A word of caution

The animation can flicker quite a bit at times, so please take care if you are sensitive to those kind of things!

Project status

Functional work in progress. I do intend to add more features sometime in the future.

Screenshots

Rule 18 starting from a single cell Rule 73 starting from random cells Rule 105 starting from a single cell Rule 126 starting from random cells

Tech/framework used

The ncurses library, wrapped in C++, is used to render all graphics on the terminal. (It needs to be installed on your system in order to compile the program! Simply consult homebrew or the package manager of your choice..)

Features

The ncurses-Cellular-Automaton is a command line program with a text-based user interface. It's a real-time implementation, that allows for continuous animation or stepwise operation. Both rule and initial conditions can be set or randomized. Rule randomization also works when the animation is running. You can always use the output of one rule and apply a different one to it. This gives some interesting sequences (if you're lucky).

Installation

The project is built using CMake and should be easily compiled on all UNIX-based operating systems. Just run build.sh to invoke make.

configure.sh is used in case the CMakeLists.txt is updated.
rule.sh just runs the executable in the build folder.

MacOS/Linux:

  1. git clone the repository
  2. Run build.sh to compile the program

Make sure ncurses is installed on your system. Don't forget to get the development files on Linux :)
Should be something along the lines of ncurses-devel.

Windows:

Unfortunately, the ncurses library is only available to UNIX-like operating systems.
(There should be workarounds if you know your way around such things..)

How to use?

Just pass a rule number to rule.sh (or pass it to the executable) to initialise the automaton. I suggest maximizing the terminal window beforehand to get the most detailed patterns. A hacky way to add more cells is decreasing the font size of your terminal, though the interface can become hard to read, if you go too far. Resizing the window or font needs to be done before the program is started.

The following keybindings control the software:

  • S Run/halt the animation
  • N Advance to next state
  • T Enter rule (0-255) (<- TODO: Fix bug that crashes program occasionaly on entering new rule manually)
  • R New random rule
  • X Reset to initial state
  • I Toggle randomization of inital conditions
  • Q Quit program

The idea is to just try some things and see what the automaton comes up with. Sometimes it gives pretty suprising results, so don't hesitate to press R a couple of times while the animation is running. (If you do so starting from a single cell, you can get some cool rocket-like pixel spaceships!)

After randomizing the rule it can sometimes happen, that the automaton goes to a state of all black or white cells. If this occurs, you have to restart by pressing X to get back to other patterns again.

Documentation

Documentation files are not hosted currently, but they are included in the project files. Open /documentation/html/index.html in your browser to access the documentation in case you want an easier time understanding the code.

License

The ncurses-Cellular-Automaton project is licensed under the BSD-2-Clause.

Copyright © 2021 Butch Warns

ncurses_cellular_automaton's People

Contributors

butchwarns avatar

Stargazers

now_its_dark avatar Patrick Pedersen avatar Hamza avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.