tic tac toe

26
FORMAT OF TERM PAPER 1. Title page of project report 2. Table of contents 3. Introduction 4. Proposed system i. Description ii. System requirements 5. Requirement Analysis 6. System Design 7. Source code 8. Testing 9. Future scope of project

Upload: yogesh-gandhi

Post on 22-Nov-2014

1.673 views

Category:

Documents


36 download

TRANSCRIPT

Page 1: TIC TAC TOE

FORMAT OF TERM PAPER

1. Title page of project report2. Table of contents3. Introduction4. Proposed system

i. Descriptionii. System requirements

5. Requirement Analysis6. System Design7. Source code8. Testing9. Future scope of project

Page 2: TIC TAC TOE

OF

(TIC TAC TOE)

Submitted in the partial fulfillment of the Degree of Bachelor of Technology (Integrated)

InComputer Science and Engineering

SUBMITTED BY:- GUIDED BY:Name ANIL KUMAR Miss Sukhdilpreet KaurRegd. No.10802020RollnoR246B55

SUBMITTED TODepartment of Computer Science and Engineering Lovely Professional University

Phagwara

Page 3: TIC TAC TOE

ACKNOWLEDGEMENT

I take this opportunity to present my votes of thanks to all those guidepost who really acted as lightening pillars to enlighten our way throughout this project that has led to successful and satisfactory completion of this study.We are really grateful to our HOD Mr. Rohit Dhand for providing us with an opportunity to undertake this project in this university and providing us with all the facilities. We are highly thankful to Miss Sukhdilpreet Kaur for her active support, valuable time and advice, whole-hearted guidance, sincere cooperation and pains-taking involvement during the study and in completing the assignment of preparing the said project within the time stipulated.Lastly, We are thankful to all those, particularly the various friends , who have been instrumental in creating proper, healthy and conductive environment and including new and fresh innovative ideas for us during the project, their help, it would have been extremely difficult for us to prepare the project in a time bound framework.

Name ANIL KUMAR Regd. No.10802020 Roll No.R246B55

Page 4: TIC TAC TOE

TABLE OF CONTENTS

1. Introduction2. Proposed system

i. Descriptionii. System requirements

3. Requirement Analysis4. System Design5. Source code6. Testing7. Future scope of project

Page 5: TIC TAC TOE

INTRODUCTION

In the existing system, most of the records are maintained on paper. It becomes very inconvenient to modify the data. In the existing system, here is a possibility that the same data in different registers may have different values which means the entries of the same data do not match. This inconsistent state does not supply the concrete information which poses a problem in the case information related to particular search record.Our project is very useful. User is no longer required to check his register in search of records, as now it can be searched over the software by choosing some options. The user need not to type in most of the information. He/she is just required to enter the desired options. On the whole it liberates the user from keeping lengthy manual records. In a nutshell, it abates the work load of an organization.

In today’s world, no one likes to perform calculations on calculator or manually when computer is there. Every one wants his/her work to be done by computer automatically

and displaying the result for further manipulations.

Page 6: TIC TAC TOE

PROPOSED SYSTEM

The following documentation is a project the “Name of the term paper allotted”. It is a detailed summary of all the drawbacks of the old system and how the new proposed system overcomes these shortcomings. The new system takes into account the various factors while designing a new system. It keeps into the account the Economical bandwidth available for the new system. The foremost thing that is taken care of is the Need and Requirements of the User.

DESCRIPTIONBefore developing software we keep following things in mind that we can develop powerful and quality softwarePROBLEM STATEMENT

o Problem statement was to design a module:o Which is user friendlyo Which will restrict the user from accessing other user’s data.o Which will help user in viewing his data and privileges.o Which will help the administrator to handle all the changes.

FUNCTIONS TO BE PROVIDED:The system will be user friendly and completely menu driven so that the users shall have no problem in using all options.

o The system will be efficient and fast in response.o The system will be customized according to needs.

SYSTEM REQUIRMENTSOperating system: MS Windows XP or Windows VistaLanguage: C LanguageProcessor: Pentium IV ProcessorRAM: 512 MBHard disk: 5 GB

Page 7: TIC TAC TOE

REQUIREMENT ANALYSIS

This process is adopted when management of the system development, Personnel decide that the particular system needs improvement. The system development life cycle is the set of activities, carried out by the analyst, designers and users to develop and implement a system. The systems that are present in the nature follow common life cycle pattern. For example consider the raining system. Initially the rain falls into the river, river flows into sea, the sea water evaporates to form vapors, the vapors form clouds which again bring rain. Similarly consider a man made system initially a system is analyzed, designed and made operational by the efforts of system analysis. After successful operation or a number of users, the system becomes less and less effective by change in the environment. So these changes have to be incorporated in to the system by minor modifications. So the general activities from the life cycle of the system are given below:

Select ion and identification of the system to be studied Preliminary study Defining the system Design and development of the system Implementation of the system

Page 8: TIC TAC TOE

SYSTEM DESIGN

Then we began with the design phase of the system. System design is a solution, a “HOW TO” approach to the creation of a new system. It translates system requirements into ways by which they can be made operational. It is a translational from a user oriented document to a document oriented programmers. For that, it provides the understanding and procedural details necessary for the implementation. Here we use Flowchart to supplement the working of the new system. The system thus made should be reliable, durable and above all should have least possible maintenance costs. It should overcome all the drawbacks of the Old existing system and most important of all meet the user requirements.

WELCOME TO GAME TIC TAC TOE

Enter your choice ?

START CHOICE QUIT

Do you want to continue?

START

STOP

Page 9: TIC TAC TOE

SOURCE CODE

#include<iostream.h>#include<stdio.h>#include<conio.h>#include<graphics.h>#include<stdlib.h>#include<string.h>#include<dos.h>

void*message;int select(int mult){ union REGS inregs, outregs ; int bli=1,use=1,key=34,i; settextstyle(2,0,5); while(key!=28) { if(bli>0) { use=bli; setfillstyle(1,0); bli=0-bli; } else if(bli<0) { use=0-bli; setfillstyle(1,8); bli=0-bli; } floodfill(221,111+use*40,15); delay(100); if(bli<0) { key=kbhit(); if(kbhit()) {

inregs.h.ah = 0 ;int86(22, &inregs, &outregs) ;key=outregs.h.ah;

} }

Page 10: TIC TAC TOE

if((key==72)&&(use>1)) { bli=use-1; } if((key==80)&&(use<mult)) { bli=use+1; } } if(bli<0) bli=0-bli; return(bli);}void box(char mes[50]){ putimage(5,5,message,0); settextstyle(0,0,1); outtextxy(20,30,mes);}void draw(char mn[3][3]){ char as[3][3][3]; char num[9][3]; for(int i=0;i<10;i++) { strcpy(num[i]," "); num[i][0]=char(49+i); } for(i=0;i<3;i++) for(int j=0;j<3;j++) strcpy(as[i][j]," "); for(i=0;i<3;i++) { for(j=0;j<3;j++) {as[i][j][0]=mn[i][j];} } clearviewport(); setcolor(15); rectangle(0,0,639,479); setfillstyle(1,8); settextstyle(0,0,1); for(i=0;i<3;i++) { rectangle(192,117+i*85,267,192+i*85); outtextxy(260,185+i*85,num[0+i*3]); rectangle(277,117+i*85,352,192+i*85); outtextxy(345,185+i*85,num[1+i*3]); rectangle(362,117+i*85,437,192+i*85); outtextxy(430,185+i*85,num[2+i*3]);

Page 11: TIC TAC TOE

} floodfill(500,430,15); setcolor(15); settextstyle(1,0,4); for(i=0;i<3;i++) { outtextxy(221,135+i*85,as[i][0]); outtextxy(306,135+i*85,as[i][1]); outtextxy(391,135+i*85,as[i][2]); }}void main(){clrscr();int gd=DETECT,gm;initgraph(&gd,&gm,"");message=malloc(imagesize(5,5,634,55));setcolor(15);rectangle(5,5,634,55);setfillstyle(1,RED);floodfill(30,30,15);outtextxy(10,10,"Message:-");getimage(5,5,634,55,message);char col[3][3],input,madu,comps,hums,mess[70]={"computer has selected the symbol . Press any key to continue.."};int exii,dang[8],my[8],hard,many,result,guess=7,bre,mad=2,count=0,dont=0,play[8],p,q,end=0,note,inpu,first,use;do{guess=7;mad=2;count=0;dont=0;end=0;result=0;for(int i=0;i<8;i++)play[i]=0;many=0;exii=1;clearviewport();setcolor(15);rectangle(0,0,639,479);rectangle(20,320,620,460);rectangle(220,150,390,180);rectangle(240,155,370,175);setfillstyle(1,8);floodfill(100,100,15);setcolor(15);settextstyle(4,0,4);outtextxy(200,50,"TIC TAC TOE");settextstyle(3,0,1);outtextxy(40,290,"How to play :-");

Page 12: TIC TAC TOE

outtextxy(35,330,"In this Game, you may select your symbol. You musttryattain");outtextxy(26,350,"three of your symbols in a line. if you suceed you are the winner.");outtextxy(35,370," But at the same time you should prevent the computer from");outtextxy(35,390,"getting three of its symbols in a line. To play enterthe number");outtextxy(32,410,"associated with the place where you want to play.Press any key");outtextxy(35,430,"to start");settextstyle(2,0,6);outtextxy(258,155,"Start Game");select(1);hard=2;for(int j=0;j<8;j++){dang[j]=0;my[j]=0;play[j]=0;}for(j=0;j<3;j++){ for(int k=0;k<3;k++) col[j][k]=' '; }draw(col);box("Please type in your symbol");hums=getche();if((hums!='X')&&(hums!='x'))comps='X';elsecomps='0';mess[33]=comps;box(mess);getch();randomize();first=(int(rand()%100));if(hard==2)guess=(int(rand()%100));else guess=5;if((first%4)>=2){use=guess%3;box("Computer has the first chance to play!");}else{use=3;mad=0;box("You have the first chance to play!");}delay(2000);do{for(int j=0;j<8;j++){dang[j]=0;my[j]=0;}count++;mad++;bre=0;if((end!=1)&&(mad!=1))

Page 13: TIC TAC TOE

{switch(use){ case 0:{ switch(count)

{ case 1: col[2][2]=comps;break; case 2: {if(col[1][1]==hums)

{col[0][0]=comps;play[0]=1;} else if((col[2][0]==hums)||(col[2][1]==hums)) {col[0][2]=comps;play[1]=1;} else if((col[0][1]==hums)) {col[0][2]=comps;play[3]=1;} else if((col[1][0]==hums)) {col[2][0]=comps;play[4]=1;} else if((col[0][2]==hums)||(col[1][2]==hums)) {col[2][0]=comps;play[2]=1;} else if (col[0][0]==hums) {col[0][2]=comps;play[3]=1;} else dont=1; }break;

case 3:{if(play[0]==1) dont=1; else if((play[1]==1)&&(col[1][2]==hums)) {col[0][0]=comps;} else if((play[2]==1)&&(col[2][1]==hums)) {col[0][0]=comps;} else if((play[3]==1)&&((col[2][1]==hums)||(col[1][2]==hums)))

{col[2][0]=comps;} else if((play[4]==1)&&(col[2][1]==hums))

{col[0][2]=comps;} else

dont=1; }break;

case 4:dont=1;break; } }break;

case 1:{switch(count) { case 1:col[0][1]=comps;break; case 2:{if(col[2][0]==hums)

col[0][0]=comps; else if(col[1][0]==hums) col[0][0]=comps; else if(col[0][2]==hums) col[1][0]=comps; else if(col[1][2]==hums) col[0][2]=comps;

Page 14: TIC TAC TOE

else if(col[0][0]==hums) col[1][2]=comps; else if(col[2][2]==hums) col[0][2]=comps; else if(q<=1) col[2][2]=comps; else col[2][0]=comps; } break;

case 3:dont=1; }

}break; case 2:{switch(count)

{ case 1:col[1][1]=comps;break; case 2:dont=1; } }break;

case 3:{dont=1; }break;

}if(dont==1){for(int i=0,l=2;i<3;i++,l--){if(col[i][i]==hums) dang[0]++;else if(col[i][i]==comps) my[0]++;if(col[i][l]==hums) dang[1]++;else if(col[i][l]==comps) my[1]++;}for(j=0;j<3;j++){ for(int k=0;k<3;k++) { if(col[j][k]==hums)

dang[j+2]++; else if(col[j][k]==comps)

my[j+2]++; if(col[k][j]==hums)

dang[j+5]++; else if(col[k][j]==comps)

my[j+5]++;

Page 15: TIC TAC TOE

}}for(int j=0;j<8;j++){if((my[j]==3)||(dang[j]==3)||(count==5))end=1;if((dang[j]==2)&&(my[j]!=0))dang[j]=0;if((my[j]==2)&&(dang[j]==0)){my[j]=3;bre=1;}}if(bre==1){for(j=0;j<8;j++) dang[j]=0;}if((dang[0]==2)||(my[0]==3)) { for(int i=0;i<3;i++) { if(col[i][i]==' ') col[i][i]=comps;

}}else if((dang[1]==2)||(my[1]==3)) { for(int i=0,l=2;i<3;i++,l--) { if(col[i][l]==' ')

col[i][l]=comps; }}

elseif((dang[2]==2)||(my[2]==3)||(dang[3]==2)||(my[3]==3)||(dang[4]==2)||(my[4]==3)){for(j=0;j<3;j++) {if((dang[j+2]==2)||(my[j+2]==3)) for(int k=0;k<3;k++) {if(col[j][k]==' ')

{col[j][k]=comps;bre=1;}} }}elseif((dang[5]==2)||(my[5]==3)||(dang[6]==2)||(my[6]==3)||(dang[7]==2)||(my[7]==3)){for(int j=0;j<3;j++) {if((dang[j+5]==2)||(my[j+5]==3))

Page 16: TIC TAC TOE

for(int k=0;k<3;k++) {if(col[k][j]==' ')

{col[k][j]=comps;bre=1;}} }}else if(col[1][1]==' ')col[1][1]=comps;else if((use==2)&&(col[2][2]==' '))col[2][2]=comps;else if((use==2)&&(col[0][2]==' '))col[0][2]=comps;elseif((((col[0][0]==hums)&&(col[2][2]==hums))||((col[0][2]==hums)&&(col[2][0]==hums)))&&(col[1][2]==' '))col[1][2]=comps;elseif((col[1][1]!=hums)&&((col[0][0]==hums)||(col[2][2]==hums))&&((col[0][1]==hums)||(col[1][2]==hums))&&(col[0][2]==' '))col[0][2]=comps;elseif((col[1][1]!=hums)&&((col[0][0]==hums)||(col[2][2]==hums))&&((col[1][0]==hums)||(col[2][1]==hums))&&(col[2][0]==' '))col[2][0]=comps;elseif((col[1][1]!=hums)&&((col[0][2]==hums)||(col[2][0]==hums))&&((col[2][1]==hums)||(col[1][2]==hums))&&(col[2][2]==' '))col[2][2]=comps;else

if((col[1][1]!=hums)&&((col[0][2]==hums)||(col[2][0]==hums))&&((col[0][1]==hums)||(col[1][0]==hums))&&(col[0][0]==' '))col[0][0]=comps;else if((col[1][1]!=comps)&&(col[2][2]==' '))col[2][2]=comps;else if((col[1][1]!=comps)&&(col[0][2]==' '))col[0][2]=comps;else if(col[0][0]==' ')col[0][0]=comps;else if(col[2][2]==' ')col[2][2]=comps;else if(col[0][1]==' ')col[0][1]=comps;else if(col[1][2]==' ')col[1][2]=comps;else if(col[0][2]==' ')col[0][2]=comps;else if(col[2][0]==' ')col[2][0]=comps;else if(col[1][0]==' ')col[1][0]=comps;else if(col[2][1]==' ')

Page 17: TIC TAC TOE

col[2][1]=comps;}for(int i=0;i<8;i++){if(my[i]==3)end=1;}}star:draw(col);box(" ");if(end!=1){box("play");madu=getche();if((int(madu)<49)||(int(madu)>57)){box("INVALID ENTRY!");for(long double jk=0;jk<99999999;jk++);goto star;}inpu=int(madu)-48;p=(inpu-1)/3;switch(inpu%3){case 0:q=2;break; case 1:q=0;break; case 2:q=1;break; }if(col[p][q]!=' '){box("Space is already occupied!");for(long doublejk=0;jk<99999999;jk++);goto star;}col[p][q]=hums;}for(j=0;j<8;j++){dang[j]=0;my[j]=0;}for(int i=0,l=2;i<3;i++,l--){if(col[i][i]==hums) dang[0]++;else if(col[i][i]==comps) my[0]++;if(col[i][l]==hums) dang[1]++;else if(col[i][l]==comps) my[1]++;}for(j=0;j<3;j++){ for(int k=0;k<3;k++) {

Page 18: TIC TAC TOE

if(col[j][k]==hums)dang[j+2]++;

else if(col[j][k]==comps)my[j+2]++;

if(col[k][j]==hums)dang[j+5]++;

else if(col[k][j]==comps)my[j+5]++;

}}for(j=0;j<8;j++){if((my[j]==3)||(dang[j]==3)) end=1;}}while((end!=1));draw(col);for(int asd=0;asd<6;asd++){many=many+1; if((my[0]==3)||(dang[0]==3)) {exii=0; if(many%2==1) for(int m=0,n=0;m<3;m++,n++) { setfillstyle(1,BLUE);floodfill(193+m*85,118+n*85,15); } else for(int m=0,n=0;m<3;m++,n++) { setfillstyle(1,BLACK);floodfill(193+m*85,118+n*85,15); }} else if((my[1]==3)||(dang[1]==3)) {exii=0; if(many%2==1) for(int m=0,n=2;m<3;m++,n--) { setfillstyle(1,BLUE);floodfill(193+m*85,118+n*85,15); } else for(int m=0,n=2;m<3;m++,n--) { setfillstyle(1,BLACK);floodfill(193+m*85,118+n*85,15); }} else for(j=2;j<8;j++) {if(((my[j]==3)||(dang[j]==3))&&(j<5)) {exii=0; if(many%2==1) for(int m=0,n=j-2;m<3;m++) { setfillstyle(1,BLUE);floodfill(193+m*85,118+n*85,15); } else for(int m=0,n=j-2;m<3;m++) { setfillstyle(1,BLACK);floodfill(193+m*85,118+n*85,15); }} else if((my[j]==3)||(dang[j]==3)) {exii=0; if(many%2==1)

Page 19: TIC TAC TOE

for(int m=0,n=j-5;m<3;m++) { setfillstyle(1,BLUE);floodfill(193+n*85,118+m*85,15); } else for(int m=0,n=j-5;m<3;m++) { setfillstyle(1,BLACK);floodfill(193+n*85,118+m*85,15); }} }for(long double jk=0;jk<9999999;jk++);if(exii==1)break;}for(int m=0;m<8;m++) { if(my[m]==3) result=1; }for(m=0;m<8;m++) { if(dang[m]==3) result=2; }switch(result){case 1:box("You loose! Want to try again(y/n)");break; case 2:box("You win! Want to try again(y/n)");break; default:box("The game is draw! Want to try again(y/n)");break;}input=getche();}while(input=='Y'||input=='y');clearviewport();setlinestyle(3,4,6);outtextxy(80,150,"This game is developed by SUNDEEP YADAV");outtextxy(170,175,"from the PROGRAMME B.TECH-M.TECH-C.S.E(246)");delay(4000);for(long double mas=0;mas<=99999999;mas++);exit(0);}

Page 20: TIC TAC TOE

TESTING

Testing is the major control measure used during software development. Its basic function is to detect errors in the software. During requirement analysis and design, the output is a document that is usually textual and no executable. After the coding phase, computer programs are available that can be executed for testing purpose. This implies that testing not only, has to uncover errors introduced during coding, but also errors introduced during previous phase. Thus the goal of testing is to uncover the requirements, design and coding errors in the programs. So after testing the outputs of my project are as follows:

** Paste the outputs of your project

Page 21: TIC TAC TOE

FUTURE SCOPE OF THE PROJECT

Our project will be able to implement in future after making some changes and modifications as we make our project at a very low level. So the modifications that can be done in our project are:

In future one change can be done by adding the fingerprints of the persons of which the address is entered.And one more major change which can be done in this project is that to add the snaps of the person of which the address is entered.We can also add or subtract details of the individual.