Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Create Conway's Game of Life With Python (Summary)

You’ve implemented Conway’s Game of Life using Python and object-oriented programming. To make the game usable, you’ve built a user-friendly command-line interface using argparse. In the process, you’ve learned how to structure and organize a CLI app and set up the application for distribution and installation. That’s a great set of skills for you as a Python developer.

In this video course, you’ve learned how to:

  • Implement Conway’s Game of Life algorithm using OOP
  • Write a curses view to display the Game of Life grid
  • Provide the game with an argparse command-line interface
  • Set up the game for installation and execution

With all this knowledge and skill, you’re ready to start digging into more complex projects and challenges. But before you put this project to bed, you have some homework to do:

Once you’ve finished your homework, you can move on to another project:


Sample Code (.zip)

22.0 KB

Course Slides (.pdf)

1.1 MB

00:00 In the previous lesson, I showed you how to use pyproject.toml to define a package for your program. In this lesson, I’ll summarize the course and point you at possible future projects.

00:12 Cellular Automata are grid-based systems populated by a current state and next state rules. Conway’s Game of Life is a specific type of cellular automata that uses a 2D square-based grid and an alive or dead state system.

00:28 In the course, I showed you several different ways of storing the state for a program like the Game of Life. Finally, settling on using sets of coordinates that represent the cells in the game that are in the alive state.

00:41 You saw how the curses library gets used to write data to the terminal, giving you the ability to create text-based animations, and then you used argparse and __main__ to turn your program into command line runnable software.

00:55 Finally, to top it all off, you packaged everything up by creating a pyproject.toml file, taking advantage of the script hook mechanism so your users can call the program directly.

01:09 If you’re looking for ways to expand your new program, consider adding another view. I bet you knew I’d say that. Two possible styles of views would be the rich library or the tkinter GUI library.

01:24 If you’re happy with curses, that just sounds funny. You could add more patterns or allow a filename to be passed to the program with other patterns in it.

01:33 Consider how that will affect the --all argument and the choices feature of the --pattern argument,

01:41 or if you’d like to see other kinds of life, there is a rich world of cellular automata out there. This link shows variations on the game, some of which have more than two states.

01:52 You could try implementing some of those if you’re looking for more build-it content from Real Python. These tutorials may be of interest to you. Links to them all are in the section below.

02:07 I hope this course was interesting for you. Thanks for your attention.

Become a Member to join the conversation.