/game-of-life

Ruby implementation of Convoy's Game of Life

Primary LanguageRuby

Gameoflife

Problem Description

As a fan of games, I want to model Convoy's game of life, with game starting from initial life state so that I can return state of life after each iteration.

Requirements

  • Any live cell with fewer than two live neighbours dies, as if by underpopulation.
  • 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 overpopulation.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Installation

Add this line to your application's Gemfile:

gem 'gameoflife'

And then execute:

bundle

Or install it yourself as:

gem install gameoflife

Limitation

  • Throws error when memory limit exceeded.

Development

Prerequisites

  • RVM or RBENV. See respective website for installation instructions.
  • Bundler (>= 2.0.1). Install using gem install bundler

Setup

After checking out the repo,

  • Run rvm use or rbenv local to switch to the configured Ruby version for this project.
  • Run bundle install --path vendor/bundle to install dependencies.

Run Instructions

  • Run ruby lib/gameoflife/application.rb

Input Instructions :

  • Either use predefined patterns or custom input as follows

First input number (N) of live cells initially. Next N Lines, enter zero indexed row and column of live cells. Enter how many iterations(X) you want to view ?

Demo

Glider

Running Tests

  • Run rake spec to run all RSpec specs inside spec.
  • Run rake lint to run RuboCop linter.

To install this gem onto your local machine, run bundle exec rake install.