Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

oldfartdeveloper/sproutcore-jasmine-game-of-life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BDD Game of Life Application in SproutCore Using Jasmine

Gregory Moeck, Brendon Murphy, James Gary, and Scott Smith (OldFartDeveloper) sat down to BDD Conway's Game of Life using SproutCore with Ki, the future SproutCore statechart framework, and Jasmine.

OldFart has continued development as a learning exercise, especially since the game seems like an excellent candidate for applying statecharts.

Rules of the Game

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Any live cell with two or three live neighbours lives on to the next generation.

Any live cell with more than three live neighbours dies, as if by overcrowding.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

How our Implementation Handles some Issues

The game board will start out with a user-set "X" and "Y" axis sizes. The user will be able to seed the game on any of the squares that he chooses. The two dimensions will grow automatically as required as the cells encounter the "border" of the grid. The game always tries to keep the live cells in view. If the colony grows too large to be seen by the existing view, the grid will automatically reduce its cell size to bring them all back. The cell reduction stops when the cell dimension is one pixel on a side. When the fully-reduced grid is no longer large enough to contain all the live cells, the game stops ticking.

Test Tool Selection

This uses the Jasmine test framework instead of QUnit because the participants all agreed they preferred Jasmine's more extensive feature set and because they life the rspec paradigm instead of the conventional unit test.

Prerequisites

  • Has been tested under Ruby 1.9.2-p136.

Installation

$ gem install sproutcore -v 1.5.0.pre.5
$ cd <your directory containing your projects>
$ git clone git@github.com:oldfartdeveloper/sproutcore-jasmine-game-of-life.git life
$ cd life
$ mkdir frameworks
$ cd frameworks
$ git clone git@github.com:FrozenCanuck/Ki.git
$ git clone git@github.com/gmoeck/jasmine-sproutcore.git
$ cd ..

Running the Application

$ sc-server

To see the application

To see the test results

Acknowledgements

  • Thanks to Greg Moeck for driving down to our Orange County hackfest and leading us in learning Jasmine and SproutCore. Am using his jasmine-sproutcore project.
  • Thanks to rvm

About

4 developers BDD'ing the game of life using Sproutcore and Jasmine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published