Giter VIP home page Giter VIP logo

langtons-ant's Introduction

Langton’s ant

Langton’s ant simulation made in C using SDL2.

Description

Simple single-source simulation of langton’s ant, made in under 500 lines of C.

Some of the main features:

  • Custom grid size and delay at runtime.
  • Very easy to modify color palette with no size limit. Supports 4 possible rotations when stepping on each color. Modified at compile-time.
  • Unlimited number of ants at runtime, spawned by clicking on the grid.
  • Grid overlay with g.
  • Single stepping with Left arrow or automatic stepping with Space.
  • Easily customizable by changing macros inside the source.

Building

Clone the repository and run make. Make sure you have SDL2 installed.

$ git clone https://github.com/8dcc/langtons-ant
$ cd langtons-ant
$ make
...

Usage

You can specify the width, height and delay at runtime.

$ ./langtons-ant
Grid size: 100x100
Cell size: 5 px
Delay: 10 ms

Step: 536

$ ./langtons-ant 50 20 200
Grid size: 50x20
Cell size: 5 px
Delay: 200 ms

Step: 231

You can use the following keys:

KeyDescription
qQuit the program.
ESCSame as q.
gToggle grid overlay.
Left ArrowSingle step.
SpaceToggle auto-stepping.
Up ArrowIncrease number of steps per frame when auto-stepping.
Down ArrowDecrease number of steps per frame when auto-stepping.
Left ClickAdd ant at the specified position.
Right ClickRemove ant at the specified position.

Screenshots

Different ants with default color palette:

https://i.imgur.com/vZMhVev.png

Single ant with 9 color palette and custom rotations:

https://i.imgur.com/8khDVKx.png

langtons-ant's People

Contributors

8dcc avatar deboogerxyz avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

deboogerxyz

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.