O'Reilly logo

Python Without Fear, First Edition by Brian Overland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required