tic tac toe term project by: salik aziz khan ramsha kausar ushna shaikh (

15
TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH ( DATA STRUCTURES AND ALGORITHMS

Upload: lila-williams

Post on 31-Dec-2015

18 views

Category:

Documents


0 download

DESCRIPTION

DATA STRUCTURES AND ALGORITHMS. TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH (. INTRODUCTION. The project that we worked on is a well known game called “Tic Tac Toe”. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

TIC TAC TOETERM PROJECT BY:

SALIK AZIZ KHANRAMSHA KAUSARUSHNA SHAIKH (

DATA STRUCTURES AND ALGORITHMS

Page 2: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

INTRODUCTION

The project that we worked on is a well known game called “Tic Tac Toe”.

We implemented this game using a binary tree which is a very flexible data structure along with some other data structures namely link lists & multi dimensional arrays.

Page 3: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

What is Tic Tac Toe?

Tic-tac-toe, also spelled tick tack toe, or noughts and crosses is a pencil paper game for two players, X and O, who take turns marking the spaces in a 3×3 grid.

The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game.

Page 4: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

How is it played?

Choose which player will be represented by X and which by O.

Let player X go first to put an X in any of the nine sections of the grid.

The players take turns putting their symbol on the table.

The first player to have 3 of their symbols in a row, whether it is horizontally, vertically, or diagonally, is the winner.

Page 5: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

EXAMPLE

Page 6: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

Binary tree

A binary tree is a tree data structure in which each node has at most two child nodes, usually distinguished as "left"

and "right". Nodes with children are parent

nodes, and child nodes may contain references to their parents.

Any node in the data structure can be reached by starting at root node and repeatedly following references to either the left or right child.

Page 7: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

Java Applet

JButton JLabel File streaming

Page 8: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

ALGORITHM

Page 9: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

CLASSES

Following classes were used in our program:

tttappNodeAI

Page 10: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

IMPORTED FILES

java.util.* java.io.* java.awt.* javax.swing.* java.awt.event.* Firstedge(text file) Firstcorner(text file)

Page 11: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

METHODS

AI() setstate() match() load() searchstate() nextmove() display() compwin() compwins() userwins() chktie() getc() actionperformed() init()

Page 12: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

FIRST CORNER

Page 13: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

FIRST EDGE

Page 14: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (

LIMITATIONS

Only two strategies i.e. first-corner and first-edge are taken into consideration while developing the program’s logic.

The computer always goes first.

Page 15: TIC TAC TOE TERM PROJECT BY: SALIK AZIZ KHAN RAMSHA KAUSAR USHNA SHAIKH  (