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

Post on 31-Dec-2015

18 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

TIC TAC TOETERM PROJECT BY:

SALIK AZIZ KHANRAMSHA KAUSARUSHNA SHAIKH (

DATA STRUCTURES AND ALGORITHMS

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.

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.

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.

EXAMPLE

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.

Java Applet

JButton JLabel File streaming

ALGORITHM

CLASSES

Following classes were used in our program:

tttappNodeAI

IMPORTED FILES

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

METHODS

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

FIRST CORNER

FIRST EDGE

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.

top related