You are on page 1of 15

SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE

PBL II REPORT ON

Artificial Intelligence
SUBMITTED TO THE SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE
IN THE FULFILLMENT OF THE REQUIREMENT
OF
Project Based Learning-II
Second Year (E&TC Engineering)
Academic Year 2022-23
BY

Name of Students Roll no


1) Himanshu Kale 2401052
2) Rajashree Kale 2401053
3) Sagar Kale 2401054
4) Harshal Bhalerao 2401010

Under the Guidance of


Ms. T. S. Mane

DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATION ENGINEERING


STES’S SINHGAD INSTITUTE OF TECHNOLOGY AND SCIENCE
NARHE, PUNE – 411041
AY 2022-23
1
CERTIFICATE

This is to certify that the report entitled

“Artificial Intelligence: Teaching the Computer to Play Tic-Tac-Toe”

Submitted by

Name of Student: Roll No:


Himanshu Dinesh Kale 2401052

is a bonafide work carried out by them under the supervision of Ms. T. S. Mane and is approved for the
partial fulfillment of the requirement of Project Based Learning-II course in Second Year Electronics and
Telecommunication Engineering, in the academic year 2022-2023 prescribed by Savitribai Phule Pune
University, Pune.

(Ms. T. S. Mane) (Dr. V. M. Rohokale)


Guide Head
Department of E&TC Engineering Department of E&TC Engineering

(Dr. S. D. Markande)
Principal

SINHGAD INSTITUTE OF TECHNOLOGY AND SCIENCE, NARHE, PUNE– 411041

Place: Pune
Date:

2
Acknowledgement
I take this opportunity to acknowledge each and every one who contributed towards my work. I
express my sincere gratitude towards guide Ms. T. S. Mane, Assistant Professor at Sinhgad Institute of
Technology and Science, Narhe, Pune, for her valuable inputs, guidance and support throughout the
course.
I wish to express my thanks to Dr. V. M. Rohokale, Head of Electronics and Telecommunication
Engineering Department, Sinhgad Institute of Technology and Science, Narhe for giving me all the help
and important suggestions all over the Work.
I thank all the teaching staff members, for their indispensable support and priceless suggestions. I also
thank my friends and family for their help in collecting data, without their help PBL-II report have not
been completed. At the end my special thanks to Dr. S. D. Markande, Principal Sinhgad Institute of
Technology and Science, Narhe for providing ambience in the college, which motivate us to work.

Name of students Roll No Signature

Himanshu Kale 2401052

3
Contents

CHAPTER TITLE PAGE NO

1 Introduction 5
2 Problem Statement 6
3 Objectives 7
4 Overview 8
5 Theory of Project 9
6 Software and Hardware Requirements 10
7 Results 11
8 Conclusion and Future Scope 14
9 References 15

4
1. INTRODUCTION

1.1 Today we'll be discussing the Tic Tac Toe game, how to play the game and how we can teach computer
to play game against human being using programming languages.

1.2 By automating the process of playing different moves to win the game. This game will help you to play
against computer.

1.3 Tic-tac-toe also known as noughts and crosses is a paper and pencil game for two players, who take
turns marking the spaces in a 3 x 3 grid traditionally. The player who succeeds in placing three of their
marks in a horizontal, vertical or diagonal row wins the game. It is a zero-sum of perfect information
game. This means that it is deterministic, with fully observable environments in which two agents act
alternately and the utility values at the end of the game are always equal and opposite. Because of the
simplicity of tic-tac-toe, it is often used as pedagogical tool in artificial intelligence to deal with
searching of game trees. The optimal move for this game can be gained by using minimax algorithm,
where the opposition between the utility functions makes the situation adversarial, hence requiring
adversarial search supported by minimax algorithm with alpha beta pruning concept in artificial
intelligence.

5
2. PROBLEM STATEMENT

2.1 When we want to play any game, we need opponent to play against us. Sometime there is no one to
play with. So, with the help of our project anyone can play alone, Tic Tac Toe game against computer
easily.
2.2 Two players, named ‘player1’ and ‘player2’, play a tic-tac-toe game on a grid of size ‘3 x 3’. Given
an array ‘moves’ of size ‘n’, where each element of the array is a tuple of the form (row, column)
representing a position on the grid.
2.3 Players place their characters alternatively in the sequence of positions given in ‘moves’. Consider
that ‘player1’ makes the first move. Your task is to return the winner of the game, i.e., the winning
player’s name.
2.4 If there is no winner and some positions remain unmarked, return ‘uncertain’. Otherwise, the game
ends in a draw, i.e., when all positions are marked without any winner, return ‘draw’.

6
3. OBJECTIVES

3.1 Our project name is Tic-Tac-Toe game. This game is very popular and is fairly simple by itself. It is
actually a two-player game. In this game, there is a board with n x n squares. In our game, it is 3 x 3
squares. The goal of Tic-Tac-Toe is to be one of the players to get three same symbols in a row -
horizontally, vertically or diagonally - on a 3 x 3 grid.

3.2 To develop Artificial intelligence-based tic-tac-toe game for human Vs AI by implementing minimax
algorithm with adversarial search concept.

3.3 To analyse the complexity of minimax algorithm through 4x4 tic tac toe game.

3.4 To study and implement alpha-beta pruning concept for improved speed of searching the optimal choice
in tic-tac toe game.

3.5 To study optimizing methods for alpha-beta pruning using heuristic evaluation function.

7
4. OVERVIEW

4.1 This game can be played in a 3x3 grid shown in figure below. The game can be played by two players.
There are two options for players:
(a) Human (b) Computer

Fig. 3x3 Grid

4.2 For the option human, both the players are human and for the option computer, the first player is human
and the second player is computer

8
5. THEORY OF PROJECT

5.1 A player can choose between two symbols with his opponent, usual games use “X” and
“O”. If first player chooses “X” then the second player have to play with “O” and vice
versa.

Fig. Grid with numbers

5.2 A player marks any of the 3x3 squares with his symbol (may be “X” or “O”) and his aim
is to create a straight line horizontally or vertically or diagonally with two intensions:
a) Create a straight line before his opponent to win the game.
b) Restrict his opponent from creating a straight line first.

5.3 In case logically no one can create a straight line with his own symbol, the game results
a tie. Hence there are only three possible results – a player wins, his opponent (human or
computer) wins or it’s a tie.

5.4 If any player is able to draw three Xs or three Os in the following combinations then that player wins. The
combinations are:

a) 1, 2, 3 b) 4, 5, 6
c) 7, 8, 9 d) 1, 4, 7
e) 2, 5, 8 f) 3, 6, 9
g) 1, 5, 9 h) 3, 5, 7

9
6. SOFTWARE AND HARDWARE REQUIREMENTS

6.1 Software Requirements:

• Programming languages such as Python

6.2 Hardware Requirements:

• A computer with a modern processor and at least 8 GB of RAM for developing and teaching
computer to play tic tac toe
• An internet connection for accessing to get information about project

10
7. RESULTS

Fig. Output 1

11
Fig. Output 2

12
Fig. Output 3

13
8. CONCLUSION AND FUTURE SCOPE

9.1 With the basis of minimax algorithm for mathematical analysis alongside speeding up the computation
by alpha beta pruning concept and optimizing the utility function using heuristic function, the 3x3 tic
tac toe game was developed. We explored that a 3x3 tic tac toe, an adversary search technique game in
artificial intelligence, can be developed using these techniques. Increasing the size of this game would
create a huge time complexity issue with the same algorithm and techniques, for which other logics
must be further researched.
9.2 In this project we teach computer to play Tic Tac Toe game against human by using python
programming language with the help of minimax algorithm.
9.2 Looking ahead, in future keyboard functions will be added. We want to design more complex boards
for the game in future.

14
9. REFERENCES

10.1 " Head First Python" by Paul Barry


10.2 "A Simple Algorithm For Designing An Artificial Intelligence Based Tic Tac Toe Game" by Sunil

Karamchandani

10.3 W3schools Tutorials (https://my-learning.w3schools.com/tutorial/python)

10.4 G. Surma. [Online]. Available: (https://towardsdatascience.com/tic-tac-toe-creatingunbeatable-ai-

with-minimax-algorithm-8af9e52c1e7d.)

15

You might also like