14. Winning at Tic-Tac-Toe

One of the most universally played childhood games is Tic-Tac-Toe. In a three-by-three matrix, each player takes turns marking an X or an O until one player gets three in a row, horizontally, vertically, or diagonally.

Sounds simple, doesn’t it? But to handle all aspects of the game is far from trivial. This chapter attacks the problem in several steps.

Image Creating the board and permitting moves

Image Determining the winner

Image Implementing ...

Get Python Without Fear now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.