samsepi0x0 / TicTacToe-AI

A demonstration of Artificial Intelligence through the game Tic-Tac-Toe.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TicTacToe-AI!!

Python Code for AI-TicTacToe (minimax).

Description:

The above file contains the logic and the implementation of the algorithm MINIMAX(part of Game Theory), according to which, the computer computes every possible move of the opponent and tries to make optimal moves by calculating results of each move,(Both by the computer and the opponent) through recursion. To know more about the Minimax Algorithm and Game Theory, go here.

Requirements:

The code requires Python3 installed in your local system. For installation instructions, refer the Official site. For Command-Line installation, use the commands:

$ sudo apt-get update && apt-get install python3

Check your Python version using:

$ python3 --version

Usage:

Clone the directory using command:

$ git clone https://github.com/samsepi0x0/TicTacToe-AI.git

Run the python file using:

$ cd TicTacToe-AI
$ python3 board.py

How to Play:

      _____ _         _____             _____          
     |_   _(_) ___   |_   _|_ _  ___   |_   _|__   ___ 
       | | | |/ __|____| |/ _` |/ __|____| |/ _ \ / _ \
       | | | | (_|_____| | (_| | (_|_____| | (_) |  __/
       |_| |_|\___|    |_|\__,_|\___|    |_|\___/ \___|

In order to play the game, select a level for difficulty.

The expected output on running the Python file is:

          |     | 
      ----+-----+----
          |     |
      ----+-----+----
          |     |
          

The numbers between 1 to 9 represent the grid address, in the following way:

     (1) | (2) | (3) 
     ----+-----+----
     (4) | (5) | (6)
     ----+-----+----
     (7) | (8) | (9)
         

Start the game by making a move. To make a move, enter the number repersenting the cell address you want to fill. As easy as that!

Output:

When Played(Hard Level):

image

Expected Result(Hard Level):

image

Updates:

The project is open for all. Feel free to make any changes in it. The GUI is still under development and will be added soon. Till then, all suggestions are warmly accepted. Contact me at here.

About

A demonstration of Artificial Intelligence through the game Tic-Tac-Toe.

License:MIT License


Languages

Language:Python 100.0%