Skip to content

bartosz121/game-of-life-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life

Python >=3.10 implementation of Conway's Game of Life using PyQt6 Demo

How to play

Clone the project

  git clone https://github.com/bartosz121/game-of-life-python

Go to the project directory

  cd game-of-life-python

Create new virtual environment

  python -m venv env

Activate environment

  # on Linux
  source env/bin/activate

  # on Windows
  ./env/Scripts/activate

Install dependencies

  pip install -r requirements.txt

Play!

  python game_of_life/run.py

Demo

  • Start game with random alive cells

Random cells

  • Map editor (example of creating a Glider)

Copperhead spaceship

  • Load pattern from file in .cells or .rle format (Dragon) you can download a pack of patterns from here

Loading Dragon pattern from a file

Rotating Copperhead

  • Save pattern to a file (.cells or .rle format)

Saving and loading a glider

Controls

  • Press ESC to go back or pause while playing

  • While playing press M to enter Map Editor

  • Map Editor Controls

    • Left Mouse Button makes clicked cell alive
    • Right Mouse Button makes clicked cell dead
    • Press M to exit map editor and start the game
    • When saving a pattern to a file press Left Mouse Button once to select starting point, then press Left Mouse Button again to choose the end
    • After pattern from a file is loaded press:
      • Left Mouse Button to place it in the grid
      • Right Mouse Button to transpose it
      • Middle Mouse Button to transpose it over the other diagonal

Settings

You can change window size and interval timer in run.py file;

game = GameOfLife(800, 600, timer_interval=120)

All other settings (like cell width/height/color) can be changed in settings.py file, inside Settings class

TODO

  • Implement other game of life algorithms (hashlife)
  • Keep settings in JSON file instead of .py
  • Better error handling
  • Copy-Paste feature
  • Change color of the rectangle for each direction when rotating loaded pattern
  • Better GUI
  • Display game data (alive cells, generation)
  • Better performance with large resolution

About

Python implementation of Conway's Game of Life - PyQt6

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages