The Invent with Python Blog

Writings from the author of Automate the Boring Stuff.

New Extra Game: Connect Four clone

Fri 25 February 2011    Al Sweigart

I have a text version of a Connect Four clone done. The AI for it looks ahead two moves, which makes it fairly impossible to beat unless you concentrate. I was planning to use this game for a chapter on recursion in my next book, but decided to publish the code for the text-version now.

Download fourinarow.py (This is for Python 3, not Python 2)

The code has few comments, but looking at its source code might be a good exercise for someone learning to program. It's available on the book's website in the Extra section.


Learn to program for free with my books for beginners:

Sign up for my "Automate the Boring Stuff with Python" online course with this discount link.

Email | Mastodon | Twitter | Twitch | YouTube | GitHub | Blog | Patreon | LinkedIn | Personal Site