Giter VIP home page Giter VIP logo

automata's Introduction

automata

A 2D Simulator in Rust for cellular automata such as Conway's Game of Life and Langton's Ant among others. Powered by the ggez framework.

Disclaimer

This project is still under development and not all features are functional. Contributions towards expanding features and improving performance are welcome.

Installation

From Release

  1. Download the latest release for the target platform.
  2. Add the path to the binary to the system PATH environment variable.
  3. Application can be invoked using automata in the shell.

From Source

  1. Install Git, Rust and Cargo on target system.
  2. Clone this repository & change directory into it.
git clone https://github.com/manishmeganathan/automata.git 
cd automata
  1. Build the project
cargo build --release
  1. Application can be run using cargo run .. or the built binary can be invoked directly.

Usage

The Simulator currently support two automata. Conway's Game of Life and Langton's Ant. The simulator can be configured with flags that adjust the grid dimension, individual cell dimensions, simulation FPS, etc.

Example

Run the following to start the Conway's Game Of Life automata.

automata gameoflife

Run the following to start Langton's Ant with a grid of 1000x1000 pixels

automata langtonsant --grid 1000x1000

Supported flags include

  • --grid [-g] Set dimensions of the grid. Takes the format widthXheight.
  • --cell [-c] Set the cell size of the grid. Takes an int that represents the size of the cell
  • --fps [-f] Set the simulation fps.

Currently supported automata

  • Conway's Game Of Life - gameoflife
  • Langton's Ant - langtonsant

Project Structure

Simulation

This module implements the event handler and simulable trait definitions.

  • SimCell represents a trait implemented by cell structs that can be simulated.
  • SimGrid represents a trait implemented by grid structs that can be simulated.
  • Automaton represents a trait implemented by any automaton that can be simulated.
  • Simulation represents a struct that contains the simulation runtime handlers.

Commons

This module implements common tools used on different automata such as different types of cells, grids and turmites.

  • BinaryCell represents a cell state enum for cells that are either on or off.
  • CellGrid represents a grid of square cells.
  • GridCell represents an arbitrary cell on a grid.
  • GridScanner represents an iterator that scans over the entire grid.
  • Orient represents a trait implemented by directional structures.
  • Direction4 represents a enum that has variation for different cardinal directions.
  • Turmite represents a turmite on a grid that crawl/travel around.

Notes:

  • All Cells implement the SimCell trait.
  • All Grids implement the SimGrid trait.
  • Future grid implementations can include hexagonal and octagonal grids which will use 6 directional and 8 directional orientations.

GameOfLife

This module implements a struct of the same name generic over different types of grids.

  • Currently the initial state of the automata is a randomly generated balance grid. Future implementation can include states such as Gosper's Glider Gun.
  • Currently only implemented for square grids.

LangtonsAnt

This module implements a struct of the same name generic over different types of grids.

  • Currently the inital state of the automata is an empty grid. Future implementations can include randomized grids.
  • Currently only implemented for square grids.
  • Currently only supports 1 randomly placed ant. Future implementations can support predetermined ant positions and multiple ants.

automata's People

Contributors

manishmeganathan avatar

Stargazers

 avatar

Watchers

 avatar

automata's Issues

Add support for simulation pause

  • Added a key event handler in the simulation event handler for pausing the simulation when Space is pressed and unpausing on a second press.
  • Use a field in the Simulation class to indicate if a simulation is in pause/play state. And flip that state on the press of a space bar

Restructure commons crate

  • Refactor module tree to have a dedicated crate commons.
  • The commons package will contain modules for separate Cells, Grids, etc
  • It will also contain implementation for other shared resources such as Turmites.

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.