TIC TAC TOE -(Approach) 1

Helenjoy
4 min readJul 31, 2023

--

Program- (Approach) 1 in Artificial Intelligence Used for Playing the Tic-Tac-Toe Game

About the game

The game is played using paper and pencil, and there are two players, X and O. Each player gets to mark one area on a 3x3 grid.

The player who is successful in placing three of their markers in a line in one of three different orientations

either horizontally,

vertically, or

diagonally — wins the game.

This is a two-player game, where one of the participants is a real person and the other is a computer.

The goal is to design a computer programme in such a way that it has a significant advantage over human players the majority of the time.

This game, which rises in difficulty, offers players three different ways to play.

Complexity

The application of a generalisation

Their ability to communicate clearly the depth and breadth of their expertise

These methods are going to progressively become representations of what we are going to refer to as AI techniques.

Let’s say that Player 1 is X.

O, the second player

Therefore, the player who achieves three marks in a row first will be the winner of the game.

Let’s have a conversation about the data structure of a board and how the Tic Tac Toe algorithm is executed so that we can play the game.

Board Data Structure

Data Organization on the Board

Each square has a number, beginning with one and going up to nine, as seen in the accompanying image:

Board and Move in Relational Data Structures Table

Imagine there is a board with nine different vector components. Each element will have a value of

0 to indicate a blank,

1 to indicate an X player move, and

2 to indicate an O player move.

The computer can take on the role of either an X or an O player.

X is always considered to be the first player.

Move Table:

It is a vector that has 3^9 components, and each of those elements is a vector that has nine elements and represents a location on the board.

The move table has a total of 3^9(19683) items.

Sample Move The table appears to be like this as shown below:

Index Position on the Board Currently Held New Position on the Board

A few instances of possible moves based on the present situation of the board:

Program- 1 of the Algorithm for the Game of Tic Tac Toe

Follow these steps in order to make a move:

Step 1: Consider the vector (the board) to be a ternary number, and then convert it to the decimal number that corresponds to it.

Step 2: Access the vector that is saved in the move table by using the calculated number as an index to locate it there.

Step 3: The vector that was chosen in step 2 indicates how the board will look after the move that should be performed. This move should be made in order to complete the game. Therefore, the board should be equalised to that vector.

Let’s begin with a blank slate, shall we?

Step 1: First, our board should now appear like 000 000 000 (a ternary number), and you should convert it to a decimal number. The number 0 represents a decimal.

Step 2: Using the computed number, in this case 0, as an index into the move table, access the vector that is saved under the heading “New Board Position.” The newly appointed position on the board is 000 010 000.

Step 3: The vector that was chosen in step 2 (000 010 000) shows how the board will look once the move that should be performed has been executed. Therefore, the board should be equalised to that vector. When you have finished the third phase, your board should look like this.

Comments :

This program exhibits remarkable time efficiency.

However, it requires significant memory space to store the extensive Move-Table.

Creating and defining all entries in the Move-Table is a laborious task.

Moreover, expanding or enhancing the program’s capabilities proves to be challenging.

--

--

Helenjoy

Research aspirant in deep learning based video compression