Code Monkey home page Code Monkey logo

gameoflife's Introduction

Game of Life

This is a python implementation of Conway's Game of Life using the pygame module as a GUI.

Description

The purpose of this project is to provide a simple but versatile application to explore cellular automata, specifically Conway's Game of Life.

The application allows the user to create a starting grid freehand, load some common patterns or use random initialization. It also allows for frames to be saved as images if required.

Requirements

  • Python 3
  • Numpy
  • Pygame

Usage

Start by cloning the repository and using pip to install requirements. By default the application loads with a blank grid of 25x25 cells and 800x800 pixels. Cells can then be turned on by clicking on them. To start the simulation press the space-bar.

python  main.py

Settings can be changed by passing command line arguments. To add patterns set "--add_patterns True", you will then be prompted for the pattern you want to add and the position. Press Enter when finished to load the application.

usage: main.py [-h] [--num_pixels NUM_PIXELS] [--num_cells NUM_CELLS]
               [--num_frames NUM_FRAMES] [--save_frames SAVE_FRAMES]
               [--random_init RANDOM_INIT] [--add_patterns ADD_PATTERNS]

optional arguments:
  -h, --help            show this help message and exit
  --num_pixels NUM_PIXELS
                        Number of pixels in width/height
  --num_cells NUM_CELLS
                        Number of cells in width/height
  --num_frames NUM_FRAMES
                        Number of frames in simulation. Continues indefinitely
                        otherwise
  --save_frames SAVE_FRAMES
                        If True saves frames as png. Only works if num_frames
                        specified
  --random_init RANDOM_INIT
                        If True creates a randomly intialized grid
  --add_patterns ADD_PATTERNS
                        If True allows user to add predefined patterns to grid

Example usage:

python main.py --num_frames 15 --num_cells 36 --add_patterns True

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.