Coder Social home page Coder Social logo

gameoflife's Introduction


Game of Life

The Game of Life probably isn't what you think, it's a program that simulates how cells might grow or die based on a small set of rules. It was created by a British mathematician named John Conway and is sometimes called "Conway's Game of Life." This description and the image above are from Wikipedia:

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:

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

These rules, which compare the behavior of the automaton to real life, can be condensed into the following:

  1. Any live cell with two or three live neighbours survives.
  2. Any dead cell with three live neighbours becomes a live cell.
  3. All other live cells die in the next generation. Similarly, all other dead cells stay dead.

You can find examples and descriptions of the Game of Life at the following websites:
Play the Game of Life online
What is the Game of Life?
Conway's Game of Life on Wikipedia

Install the Guido GUI Library

The Game of Life is well suited to using a two dimensional array of buttons. We'll be using a GUI library called Guido to create the buttons. To install it, start Processing and choose Sketch | Import Library | Add Library. Type Guido in the search box, the click on Guido by Florian Jenett and then click Install.

Program Requirements

  1. Your Game of Life will be a two dimensional array of buttons
  2. If the user clicks on a button it should turn that cell on and off
  3. Make sure all class member variables and methods are labeled appropriately as either public or private
  4. The finished program should correctly implement the rules of the Game of Life

Suggested steps to completing this assignment:

  1. Fork and clone down this repository. As you work through the following steps, make sure that your program runs correctly before going to the next step.
  2. On line 2, delete the comment and create two integer constants NUM_ROWS and NUM_COLS and initialize them each with the value 20
  3. Go to line 13, use the constants to initialize the 2d array buttons to have 20 rows and 20 columns
  4. Use nested loops to create a new Life for each row column pair
  5. Use the constants initialize buffer to be a new 2d array of type boolean
  6. Uncomment the first two lines in the Life constructor (around line 62)
  7. In draw write nested loops to draw each button to the screen. You should now see a grid of buttons. If you click on the button it should turn off and on.

More to come

Samples of Student Work

none yet!

gameoflife's People

Contributors

simart 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.