Code Monkey home page Code Monkey logo

sfraser / multithreadedgameoflife Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 10.55 MB

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

Home Page: http://www.youtube.com/watch?v=CFCYVfApPUc

Clojure 100.00%

multithreadedgameoflife's Introduction

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

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.