SkillAgentSearch skills...

Boids

Clojure implementation of the Boids algorithm

Install / Use

/learn @scottwshaw/Boids
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated12y ago
Forks4

Languages

Clojure

Security Score

55/100

Audited on Sep 29, 2013

No findings