Code Monkey home page Code Monkey logo

game-of-life's Introduction

game-of-life

this is an implementation of conway's Game of life, with python and pygame. The Game is a 0 player game (it's a simulation) when each cell is represented by a square, it can be alive or dead. and for each generation it's evolve following the rules bellow

  • if a dead cell is surrounded by exactly 3 alive cells then she will be alive in the next generation as if by reproduction.
  • if an alive cell is surrounded by 2 or 3 alive cells it will survive on the next generation.
  • if an alive cell is surrounded by less than 2 (or more than 3) alive cells, it will die as if by underpopulation (resp by overpopulation). for more information about the game check this wikipedia page

Requirements

  • python3
  • pygame

How to run it

  1. Create a virtual environment
python3 -m venv env
  1. activate virtual environment
source env/bin/activate
  1. Install requirments
pip install requirements.txt

if it doesn't work try

pip install pygame
  1. run
python game_of_life.py

configuration

there are some configurations you can do to the JSON file config.json

you can

  1. adjust the the size of the window by modifying these parameters
"screen_size_width":1200,
"screen_size_height":800,
  1. modify the background color (color of the dead cells), and the cell color.
"background_color":"darkslategray",
"cell_color":"tomato",
  1. or the size of a cell wich will impact the number of cells in the board (smaller size imply more cells).
"cell_size_width":12,
"cell_size_height":12,

The last paramater is the initial configuration and it represent the coordinate of cells alive at the begining of the simulation

How to play it

you can add a living cell by taping the left click with the mousse, and delete a living cell with the right click.

you can use the spacebar to pause/unpause the simulation

you can use the backspace to reset the simulation (you'll kill all the cells)

game-of-life's People

Contributors

abdelhak2406 avatar aymenkhs avatar

Watchers

 avatar

Forkers

abdelhak2406

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.