Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Clojure implementation of "Conway's Game of Life" showing parallelization of the work. See http://groups.google.com/group/clojure/msg/73df9c3446bf092f for background. Thanks to Larry Sherrill for initial implementation: http://lpsherrill.blogspot.com/2009/02/conways-game-of-life.html
Clojure
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
src/org/frasers/life
MultithreadedGameOfLife.iml
MultithreadedGameOfLife.ipr
MultithreadedGameOfLife.iws
README

README

This program runs 1 to many Game of Life simulations. For more on the "Game of Life", see: 
    http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

This code uses clojure concurrency primitives to demonstrate how threads can be used to get more done in less time.
The more cores you have, the more effective a demonstration.

Each window this program opens has it's own set of threads to execute the simulation. By watching a window with 1
thread versus a window with 2, 3, or 4, you will visually see the power of parallelizing CPU intensive work.

At the start of the simulation each window starts out with the same "state". When you hit the Start button (on any
window), all the windows will start running the Game of Life. Each thread will use a specific color so that you can
visually see the parallelism of the process. The windows are assigned an increasing number of threads from 1 to the
total number of windows opened. So if you ask for 3 windows, you will get one window with 1 thread, another with 2
threads, and a third with 3.

There is a "total frames" and a "frames per second" indicator on each window so you can also get a rough feel for how
fast each window is running.

How to Run

At the top of the file set these vars:

; Dimensions of the grid - make this bigger if you have more horsepower!
(def x-cells ( * 32 2))
(def y-cells ( * 48 2))

; Size in pixels of the squares we will paint on the screen - make this smaller with larger size grids
(def cell-size 5)

Then call -main with the following params:

* number of windows you want to see
Something went wrong with that request. Please try again.