Profile picture

Tic Tac Toe

A simple command-line game (Python Scripting)

Posted on January 27, 2026

project image

                               photo credit: vecteezy.com

 

Overview

A Tic Tac Toe game, playable from the command line, was built using Python, which supports 2 modes:

  1. Two players and
  2. player vs. computer

ASCII image

photo: Screenshot showing ASCII “Tic Tac Toe” title at game start

The game includes a clear ASCII title (photo at the start of this page), a sample board that is numbered for guidance, and a real-time win/tie detection. This project helped me strengthen my understanding of game logic, state management, and breaking Python programs into clean, structured code while building something interactive and fun.

How It Works

photo: Board showing Xs and Os while the game is in progress

  • Players choose positions using numbers 1 - 9, based on a displayed sample board.

  • Player icons (X and O) are assigned automatically.

  • The game rotates turns between players and validates the inputs.

  • A computer opponent makes valid moves at random.

  • The game checks for "wins" or "ties" after every move.

photo: Screenshot showing "Player 1 (X) WINS!" message

Key Features

Board Numbering

photo: Screenshot of the numbered board explaining positions 1–9

  • ASCII Tic Tac Toe title for a better Command Line Interface (CLI) experience

  • A sample board showing correct number mapping for moves

  • The game has two modes: Player vs Player and Player vs Computer

  • There is an input validation (rejecting inputs with invalid numbers & occupied positions)

  • An automatic win and tie detection

  • There is the option to replay after a game ends

Technical Highlights

The project was channelled into five Python scripts, each responsible for a specific part of the game:

  1. main.py: This handles the game flow and each player's turns.
  2.  player_brain.py - This contains a PlayerBrain class that handles the gameboard board updates and manages player state and moves.
  3. sample_board.py – This displays the sample game board.
  4. score_checker.py - This contains a ScoreChecker class that checks rows, columns and diagonals for wins and draw conditions.
  5.  tic_tac_toe_title.py - This displays the ASCII word.

Learning Points

  • I designed reusable classes for game logic.

  • I coordinated and kept the game state consistent across different parts of the game.

  • I validated user input safely in the CLI game

 

photo: Screenshot showing "IT IS A TIE!" message

 

📂 GitHub Repository: https://github.com/John-Temitope/tic_tac_toe.git