Skip to content

DevontiaW/Games-Tic_Tac_TOE-s-

Repository files navigation

Tic Tac Toe (Noughts and Crosses)

CI

Simple, fast console Tic Tac Toe in Python, with optional AI (random or perfect play) and a tiny Tkinter UI.

Requirements

  • Python 3.8+ (Windows/macOS/Linux)
  • Tkinter (usually included with Python on Windows/macOS)

Console Usage

  • Human vs Human:
    python tic_tac_toe.py
  • Human vs Computer (AI as O):
    python tic_tac_toe.py --ai O
  • Computer difficulty:
    # random or minimax (perfect). Default: minimax
    python tic_tac_toe.py --ai O --ai-level random

Controls: enter moves as row,col with values 1–3 (example: 2,3). Type q to quit.

Tkinter UI

Run a simple windowed version:

python ui_tk.py                 # Human vs Human
python ui_tk.py --ai O          # Human (X) vs Computer (O)
python ui_tk.py --ai X          # Computer (X) vs Human (O)
python ui_tk.py --ai O --ai-level random

Tests

Run unit tests with the standard library test runner:

python -m unittest -v

Samples & Chart

  • Sample CSVs are in samples/ (random and minimax batches).
  • Generate a chart (requires matplotlib):
    pip install -r requirements.txt
    python analyze_results.py --input samples/autoplay_sample_random.csv --output samples/autoplay_sample_random.png

Sample chart:

Autoplay Results

License

Apache License 2.0 — see LICENSE.

About

Tic Tac Toe with a twist (Nought's and Crosses)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published