Code Monkey home page Code Monkey logo

game-of-life-starter's Introduction

Game of Life

Conway's "Game of Life" is a classic computer science challenge, solved by many students in many languages throughout the years. The best way to learn about it is to play it here: https://playgameoflife.com/

You will use a 2D int[][] to represent "cells". Unlike the true game, your version will not be on an infinite plane. You will use a finite Processing canvas to visualize the game.

You are given starter code. You may adjust the canvas and the cell spacing. The DENSITY constant should be used to initialize the game grid with roughly that percentage of "living" cells. I.e., if it's set to 0.1 that means that roughly 10% of the cells will be alive at the start. You will randomly populate the cells.

Note that rows are designated by y and columns by x. If you want to rename these variables you can, but be consistent!

Regeneration Rules

For a space that is populated (1):

  • Each cell with one or no neighbors dies, as if by solitude.
  • Each cell with four or more neighbors dies, as if by overpopulation.
  • Each cell with two or three neighbors survives.

For a space that is unpopulated (0):

  • Each cell with three neighbors becomes populated.
  • Otherwise, the cell remains unpopulated.

Of course, checking indexes that are out-of-bounds will throw errors. You can get creative, but you may find that there is no "clean" solution to this. You'll end up with a bunch of if/else statements...

Good luck!

game-of-life-starter's People

Contributors

cgortonbrooks avatar

Watchers

 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.