Skip to content

Commit

Permalink
docs, demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tranma committed Nov 12, 2012
1 parent 4c7d475 commit 5654eb9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import qualified Data.Array.Repa.Repr.Vector as R
import Graphics.Gloss
import Graphics.Gloss.Raster.Array
import Graphics.Gloss.Interface.Pure.Game

-- JuicyPixels-repa
import qualified Codec.Picture.Repa as J

-- base
import Control.Monad
import System.Random
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Falling Turnip is an interactive particle simulation. Like others in the same genre (typically dubbed "falling sand games"), it has some degree of approximation for gravity, fluid flow and alchemical reactions. Unlike the others, it is based entirely on cellular automata and runs in parallel.

A short demo video is available [here](http://youtu.be/hlL9yi2hGx0).

In our simulation, each pixel is a cellular automation and all physical reactions are phrased as cellular automata rules. This approach enables us to take advantage of the massively distributed/parallel nature of cellular automata, however expressing gravity and fluid behaviour as automata rules has proven challenging.

Background
Expand Down Expand Up @@ -43,6 +45,31 @@ The novelty of our simulation lies with the use of cellular automata --- a highl

This project also serves as a testament to the effectiveness of data parallelism in general and the Repa library in particular. Adding more processing cores improves performance without any added effort on the part of the programmer.


Notes
=====

Assuming you have GHC and cabal installed (if not, get the Haskell platform [here](http://www.haskell.org/platform/)), to build `falling-turnip` simply go `cabal configure && cabal build`. Alternatively, use `make`:

cabal update
cabal install gloss
cabal install gloss-raster
cabal install repa-3.2
cabal install vector
cabal install random
cabal install JuicyPixels-repa
make

Use the following run-time options for optimal performance:

+RTS -N<number of cores> -qa -qg

For example:

./Main +RTS -N7 -qa -qg

The name "Falling Turnip" comes from Repa, which stands for Regular Parallel Arrays, and also means "turnip" in Russian.

Bibliography
============
[1] J. L. Schiff, Cellular Automata: A Discrete View of the World (Wiley Series in Discrete Mathematics and Optimization).
Expand Down
2 changes: 1 addition & 1 deletion World.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE ViewPatterns, PatternGuards #-}
module World
( Element (..), Cell (..)
, Env (..)
Expand Down
26 changes: 26 additions & 0 deletions falling-turnip.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Name: falling-turnip
Version: 0.1
Author: Tran Ma
Maintainer: tranm@cse.unsw.edu.au
Build-Type: Simple
Cabal-Version: >=1.6
Description:
Falling sand game/cellular automata simulation using regular parallel arrays.

Tested-with: GHC == 7.4.1

Executable falling-turnip
Main-is: Main.hs

Build-depends:
base == 4.*,
gloss == 1.7.*,
gloss-raster == 1.7.7.*,
repa == 3.2.*,
repa-algorithms == 3.2.*,
vector == 0.9.*,
random == 1.*,
JuicyPixels-repa == 0.6.1

ghc-options:
-threaded -O3 -Odph -rtsopts -fno-liberate-case -funfolding-use-threshold1000 -funfolding-keeness-factor1000 -fllvm -optlo-O3 -with-rtsopts=-N -with-rtsopts=-qa -with-rtsopts=-qg

0 comments on commit 5654eb9

Please sign in to comment.