Skip to content

Overboard-code/Conways-Life-pygame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Conways-Life-pygame

Another version of Game of Life but using pygame_widgets

I wrote this a while back (2020) but added pygame_widgets to add buttons and a slider to mimic the keyboard functions.

You'll need to install:

  • pygame
  • pygame-widgets
  • numpy
  • webcolors

I used numpy arrays because this whole game is just a couple of arrays and numpy arrays are way faster/cheaper than pythons built in arrays.
The game is different from many versions I have seen. It uses colors to show the state of the cells.
Cells have 5 states:

  1. Empty or dead (Default state) grey
  2. New Baby Just born because 3 and only 3 'live' cells were adjacent to a dead cell - Light Green
  3. Adult surived at least one round of the game, a grown up baby has 2 or 3 'live' adjacent cells - Dark Green
  4. Dying of lonliness
  5. is and adult or baby with less than 2 adjeacent 'live' cells - Black
  6. Dying of crowding has more than 3 adjacent live cells - Maroon

I didn't use parameters to define colors and sizes Just constants in the code. Add parms if you like. By the way pygame_widgets didn't document the vertical=True/False parameter for sliders.

I set up a tic/toc to show the change in state of the cells

Keyboard Funtions to momic the buttons are:
RETURN: Play/Pause
SPACE: Single step the game
'c': clear and stop the game
'r': stop and fill with a random bunch of cells
'ESC': quit the game

About

Another version of Game of Life using pygame_widgets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages