Coders Packet

AI based Unbeatable Tic Tac Toe in C++

By Gaurav Sawant

This project is an AI based unbeatable Tic Tac Toe game which can be played between a human and a computer.

AI based Unbeatable Tic Tac Toe is a C++ program that is a game which can be played as a human with computer as the opponent.

When the game begins, the human has the choice to make the first move. Regardless of whatever move the human plays, the computer will always make the most optimal move.

So, if the human plays optimally the game would always end in a draw. If the human makes any wrong move, he would be defeated, but there is no possible way for the computer (program) to lose the game, thus it is unbeatable.

You can try any possible moves to play the game. Most optimal games would lead to a draw.

How to make the moves?


Depending on the position where the user wants to make the move, he/she has to input two numbers seperated by space as follows:

(These are actually the matrix coordinates of that particular cell)

Top Row Left Column -> 1 1

Top Row Middle Column -> 1 2

Top Row Right Column -> 1 3

Middle Row Left Column -> 2 1

Middle Row Middle Column -> 2 2

Middle Row Right Column -> 2 3

Bottom Row Left Column -> 3 1

Bottom Row Middle Column -> 3 2

Bottom Row Right Column -> 3 3

Download Complete Code


No comments yet

Download Packet

Reviews Report

Submitted by Gaurav Sawant (GauravSawant)

Download packets of source code on Coders Packet