Code Challenge 12 - Build a Tic-tac-toe Game

PyBites, Mon 27 March 2017, Challenges

AI, codechallenges, game, learning, tictactoe

There is nothing like a challenge to bring out the best in man. - Sean Connery

Hi Pythonistas, a new week, a new 'bite' of Python coding! After last week's conceptual challenge (generators), we'd like to challenge you this week to build Tic-tac-toe. Every time we do games (previously Word Values and Hangman) we learn a lot. Enjoy and we review solutions end of this week.

Details

Build a command line app where you can play against a friend or the computer. We recommend the latter to do some AI: to intelligently respond to player's moves (see Strategy). Maybe you can add game levels to avoid the machine to be 'too smart' (see Google widget for example).

For the best UX it's probably easiest to number the board like the keyboard's number pad: 7-8-9, 4-5-6, 1-2-3. We provided a template with some guidance, but maybe you want to start from scratch (let us know what works best for you ...)

Getting ready

See our INSTALL doc how to fork our challenges repo to get cracking. If you want to share your solution do a PR and we will add it to our community branch. We will feature creative solutions and learning in our review post.

Archive

You can find all our code challenges so far here. If you have ideas for a future challenge or find any issues, please contact us or open a GH Issue.

Last but not least: there is no best solution, only learning more and better Python. Good luck!


Keep Calm and Code in Python!

-- Bob and Julian

PyBites Python Tips

Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.

Get our Python Tips Book

"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H

"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B

"This is now my favourite first Python go-to reference." - Anthony L

"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S

Get the book