Giter Club home page Giter Club logo

gameoflife's Introduction

This is a Game Of Life Implementation in Java.  It contains a test class for Test Driven Development and a main class for executing the Game Of Life in a UI.  To build, import the project into your favorite Java IDE.  This was exported via command line/git from IntelliJ IDEA 15.0.5.

The game of life rules are as follows:
1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies, as if by over-population.
4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Classes are as follows:

**GameOfLife.java -- This class contains three methods:
    1. getNeighborCells - Counts surrounding cells, returns count.
    2. liveOrDie - Makes decision based of Game Of Life rules, returns 1 or 0 for new grid.
    3. cycleArray - Cycles through current array, placing 1 or 0 in new array, then returns new
    array.

**GameOfLifeMain.java -- This class creates the UI and visually executes the Game Of Life:

**TheGrid.java -- This class contains one method:
    1. generateGrid - Generates the original grid used in the game.

**GameOfLifeTest.java -- This class contains six test methods:
    1. theGridClassReturnsAGeneratedGridAndNotANull
    2. gameOfLifeMethodGetNeighborCellsReturnsAnIntegerZeroThroughEight
    3. returnsZeroIfLiveCellHasMoreThanThreeLiveNeighbors
    4. returnsOneIfLiveCellHasTwoOrThreeLiveNeighbors
    5. returnsOneIfDeadCellHasExactlyThreeLiveNeighbors
    6. TheGameOfLifeAddNeighborsReturnsANewList


**To Run the Tests for this project**
    - Run GameOfLifeTest.java

**To Run the Game Of Life UI Simulation**
    - Run GameOfLifeMain.java.  It is currently configured to simulate the 10 Cell Row pattern in a
    25x25 grid.

**To Tweak the Grid Size or pattern**
    Size -- In TheGrid.java, change height/width of grid by adjusting the corresponding integers.
    Pattern -- In TheGrid.java, enable "Random grid logic" and disable "10 Cell Row" code.

gameoflife's People

Contributors

cale146 avatar

Watchers

 avatar  avatar

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.