GithubHelp home page GithubHelp logo

boids's Introduction

Boids

This is a Clojure implementation of Craig Reynolds' original Boids flocking algorithm. The Boids algorithm simulates coordinated animal motion such as you'd see in bird flocks and fish schools.

I was at the 1987 Siggraph convention the year he presented this work. It was really revolutionary for its time and left a big impression on me. See his famous CGI simulation "Stanley and Stella in Breaking the Ice".

The rendition implemented in this program is considerably lower-fi than Craig's.

Mostly, I'm using this project to teach myself how to use Clojure and how to write proper tests in Clojure.

Installation

  1. This is Clojure, so you will need to have Java (preferably 1.6) installed on your system
  2. Download and install leiningen. The installation instructions on the leiningen github page are pretty clear, but basically, you download the script (not git clone), put it somewhere in your path and make it executable, then run lein self-install at the command line.
  3. Fork or git clone this repository
  4. In the top level Boids directory, run the command lein deps This will download and install clojure and other jars needed to build and run the project.
  5. That's it. Follow the usage instructions from there on out.

Alternatively, you can execute the shell script in the top level directory called repl but you will have to make sure the jline jar and clojure jars are in place and edit the script to reflect the location of your project and dependencies. Howeer, once you have run lein deps, they should be there in approximately the same place as mine. The repl script gives you more control over the Java classpaths and stuff.

Usage

In the top-level project directory, run

$ lein repl

This gives you a Clojure REPL with all the classpaths set for the project. Now, you can execute the following commands (in this sequence) in the REPL

Import the functions in src/boids/main.clj

user=> (use 'boids.main)

Generate a flock, f, which is a "double agent" (my term) for controlling the flock display

user=> (def f (init-flock))

Start the flock moving. Watch them fly (or swim). Whoo-hoo!

user=> (start-flock f) 

Freeze the flock in place. You can always restart with start-flock if you wish.

user=> (stop-flock f) 

Kills the flock and its window

user=> (kill-flock f) 

License

What?? Like anybody cares.

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.