PageRenderTime 8ms CodeModel.GetById 17ms app.highlight 148ms RepoModel.GetById 2ms app.codeStats 0ms

/assign3.cpp

https://github.com/ravikumarj/Alpha-beta-pruning
C++ | 1589 lines | 1269 code | 192 blank | 128 comment | 230 complexity | 5873b3b55f81c57a49f3b6dd742c9b9e MD5 | raw file
   1#include<iostream>
   2#include <vector>
   3#include <iostream>
   4#include <string>
   5#include <queue>
   6#include <stack>
   7#include <list>
   8#include <stdio.h>
   9#include <fstream>
  10#include <string.h>
  11#include<stdlib.h>
  12#include <stddef.h>
  13#include <map>
  14#include <cmath>
  15using namespace std;
  16#define PINF 65535
  17#define NINF -65535
  18int global_turn=0;
  19FILE *opf=NULL;
  20FILE *opl=NULL;
  21class Vertex;
  22
  23class Edge
  24{
  25	public:
  26		Edge(Vertex *org, Vertex *dest)
  27		{
  28			origin = org;
  29			destination = dest;
  30		}
  31
  32		Vertex* getOrigin() {return origin;}
  33		Vertex* getDestination() {return destination;}
  34	private:
  35		Vertex* origin;
  36		Vertex* destination;
  37};
  38
  39
  40class Vertex
  41{
  42	public:
  43		float cost;
  44		bool explored;
  45		//Vertex *parent;
  46		int depth;
  47		int group;
  48		int temp_group;
  49		int commit_group;
  50		Vertex(string id,float cost,int group)
  51		{
  52			depth=-1;
  53			//parent=NULL;
  54			explored=false;
  55			name = id;
  56			this->cost=cost;
  57			this->group=group;
  58			this->temp_group=group;
  59		}
  60
  61		void addEdge(Vertex *v)
  62		{
  63			Edge newEdge(this, v);
  64			edges.push_back(newEdge);
  65		}
  66		std::list<string> getFreeNeihbor(int &len)
  67		{
  68			int j=0;
  69			std::list<string> adj;
  70			//char *adj=new char[30];
  71			for (int i = 0; i < edges.size(); i++)
  72			{
  73				Edge e = edges[i];
  74				//cout<<"Neihbor "<<e.getOrigin()->getName()<<"-->"<<e.getDestination()->getName()[0]<<endl;
  75				if(e.getDestination()->group == 0)
  76				{
  77					adj.push_back(e.getDestination()->getName());
  78					//adj[j]= e.getDestination()->getName()[0];
  79				//	cout<<"Free ones-->"<<adj[j]<<endl;  	
  80					j++;
  81				}
  82			}
  83			len=j;
  84			return adj;
  85		}
  86		int opponentNeighborCost(int groupl)
  87		{
  88		float c=0;
  89		for (int i = 0; i < edges.size(); i++)
  90                        {
  91                                Edge e = edges[i];
  92                                if(e.getDestination()->group == groupl)
  93                                {
  94					//cout<<"\ngroupl\t"<<e.getDestination()->group<<","<<groupl;
  95
  96                                        c=c+ e.getDestination()->cost;
  97                                }
  98                        }
  99		//cout<<"\nOpponent's Neihbor cost -->"<<c;
 100		return c;
 101
 102		}
 103
 104		void captureOpponent()
 105		{
 106		//cout<<"\ncapture"<<!(this->group)<<endl;
 107		int groupl=0;
 108		if(this->group == 1)
 109		 groupl=-1;
 110		else if (this->group == -1)
 111		 groupl=1;
 112                for (int i = 0; i < edges.size(); i++)
 113                        {
 114                                Edge e = edges[i];
 115                                if(e.getDestination()->group == groupl)
 116                                {
 117				e.getDestination()->group=this->group;
 118                                }
 119                        }
 120
 121		}
 122
 123		void printEdges()
 124		{
 125			cout << name << ":" << endl;
 126			for (int i = 0; i < edges.size(); i++)
 127			{
 128				Edge e = edges[i];
 129				cout <<e.getOrigin()->getName()<<"-->"<< e.getDestination()->getName() << endl;
 130			}
 131			cout << endl;
 132		}
 133
 134		string getName() {return name;} 
 135		vector<Edge> getEdges() {return edges;}
 136
 137		string name;
 138		vector<Edge> edges;
 139};
 140class obj
 141{
 142	public:
 143	float cost;
 144	int group;
 145	int dest;
 146	int action;
 147	float alpha;
 148	float beta;
 149};
 150
 151struct CompareNode : public std::binary_function<obj,obj,bool>
 152{
 153	bool operator()(obj lhs, obj rhs) const
 154	{
 155		return lhs.cost < rhs.cost;
 156	}
 157};
 158
 159class Graph
 160{
 161	public:
 162		Graph() {
 163			this->depth_terminal=0;
 164			alpha_stat=-65535;
 165			}
 166
 167		void insert(Vertex *v)
 168		{
 169			vertices.push_back(v);
 170		}
 171
 172		void printGraph()
 173		{
 174			for (int i = 0; i < vertices.size(); i++)
 175				vertices[i]->printEdges();
 176		}
 177		void reset()
 178		{
 179			for (int i = 0; i < vertices.size(); i++)
 180			{
 181				vertices[i]->explored=false;
 182				//	vertices[i]->parent=NULL;
 183			}
 184		}
 185
 186		int getIndex(string nodename)
 187		{
 188			for(int i = 0; i < vertices.size(); i++)
 189			{
 190				//cout<<vertices[i]->name[0]<<"getInd"<<endl;
 191				if(vertices[i]->name ==nodename)
 192				{
 193					return i; 
 194				}
 195			}
 196			return -1;
 197
 198		}
 199		void print_glog(obj ob)
 200		{
 201		fprintf(opl,"Union,");
 202		if(ob.action==0)
 203			{
 204			fprintf(opl,"Force March,");
 205			}
 206		else
 207			{
 208			fprintf(opl,"Paratroop Drop,");
 209			}
 210		fprintf(opl,"%s,1,%.1f\n",vertices[ob.dest]->getName().c_str(),ob.cost);
 211
 212		}
 213		 void print_minmaxlog(int dest=-1,float value=-1,int action=-1,int player=-1,int depth=-1)
 214                {
 215		if(global_turn == 0)
 216		{
 217		if(dest == -1)
 218			{
 219			fprintf(opl,"N/A,N/A,N/A,0,");
 220				if(value <= -30000)
 221					{
 222					fprintf(opl,"-Infinity\n");
 223					}
 224				else if(value >= 30000)
 225					{
 226					fprintf(opl,"Infinity\n");
 227					}
 228				else
 229					{
 230					fprintf(opl,"%.1f\n",value);
 231					}
 232			}
 233		else
 234		{
 235		if(player == 1)
 236			{
 237			fprintf(opl,"Union,");
 238			}
 239		else
 240			{
 241			fprintf(opl,"Confederacy,");
 242			}	
 243                if(action==0)
 244                        {
 245                        fprintf(opl,"Force March,");
 246                        }
 247                else
 248                        {
 249                        fprintf(opl,"Paratroop Drop,");
 250                        }
 251                fprintf(opl,"%s,%d,",vertices[dest]->getName().c_str(),depth);
 252			if(value <= -30000)
 253                                        {
 254					  fprintf(opl,"-Infinity\n");
 255                                        }
 256                                else if(value >= 30000)
 257                                        {
 258					  fprintf(opl,"Infinity\n");
 259                                        }
 260                                else
 261                                        {
 262					  fprintf(opl,"%.1f\n",value);
 263                                        }
 264
 265
 266		}
 267		}
 268                }
 269		void print_prunedlog(int dest=-1,float value=-1,int action=-1,int player=-1,int depth=-1,float alpha=-1,float beta=-1,int cutoff=-1)
 270                {
 271		if(global_turn == 0)
 272		{
 273		if(dest == -1)
 274			{
 275			  fprintf(opl,"N/A,N/A,N/A,0,");
 276				if(value <= -30000)
 277					{
 278					  fprintf(opl,"-Infinity,");
 279					}
 280				else if(value >= 30000)
 281					{
 282					  fprintf(opl,"Infinity,");
 283					}
 284				else
 285					{
 286					  fprintf(opl,"%.1f,",value);
 287					}
 288
 289				if(alpha <= -30000)
 290                                        {
 291					  fprintf(opl,"-Infinity,");
 292                                        }
 293                                else if(alpha >= 30000)
 294                                        {
 295					  fprintf(opl,"Infinity,");
 296                                        }
 297                                else
 298                                        {
 299					  fprintf(opl,"%.1f,",alpha);
 300                                        }
 301
 302				if(beta <= -30000)
 303                                        {
 304					  fprintf(opl,"-Infinity");
 305                                        }
 306                                else if(beta >= 30000)
 307                                        {
 308					  fprintf(opl,"Infinity");
 309                                        }
 310                                else
 311                                        {
 312					  fprintf(opl,"%.1f",beta);
 313                                        }
 314
 315			}
 316		else
 317		{
 318		if(player == 1)
 319			{
 320			  fprintf(opl,"Union,");
 321			}
 322		else
 323			{
 324			  fprintf(opl,"Confederacy,");
 325			}	
 326                if(action==0)
 327                        {
 328			  fprintf(opl,"Force March,");
 329                        }
 330                else
 331                        {
 332			  fprintf(opl,"Paratroop Drop,");
 333                        }
 334                fprintf(opl,"%s,%d,",vertices[dest]->getName().c_str(),depth);
 335			if(value <= -30000)
 336                                        {
 337					  fprintf(opl,"-Infinity,");
 338                                        }
 339                                else if(value >= 30000)
 340                                        {
 341					  fprintf(opl,"Infinity,");
 342                                        }
 343                                else
 344                                        {
 345					  fprintf(opl,"%.1f,",value);
 346                                        }
 347
 348			 if(alpha <= -30000)
 349                                        {
 350					  fprintf(opl,"-Infinity,");
 351                                        }
 352                                else if(alpha >= 30000)
 353                                        {
 354					  fprintf(opl,"Infinity,");
 355                                        }
 356                                else
 357                                        {
 358					  fprintf(opl,"%.1f,",alpha);
 359                                        }
 360
 361                                if(beta <= -30000)
 362                                        {
 363					  fprintf(opl,"-Infinity");
 364                                        }
 365                                else if(beta >= 30000)
 366                                        {
 367					  fprintf(opl,"Infinity");
 368                                        }
 369                                else
 370                                        {
 371					  fprintf(opl,"%.1f",beta);
 372                                        }
 373
 374
 375
 376		}
 377		if(cutoff == 1)
 378			{
 379			  fprintf(opl,",CUT-OFF\n");
 380			}
 381		else
 382			{
 383			  fprintf(opl,"\n");
 384			}
 385		}
 386                }
 387
 388
 389
 390		std::list<int> fmpdCandidates(int groupl)
 391		{
 392			//int fmpdlist=new int[30];
 393			std::list<int> fmlist;
 394			int k=0;
 395			int len=0;
 396			for(int i = 0; i < vertices.size(); i++)
 397			{
 398				//cout<<"In fmpd"<<endl;
 399				if(vertices[i]->group == groupl)
 400				{
 401					//cout<<"\nInside";	
 402					std::list <string>adj=vertices[i]->getFreeNeihbor(len);
 403					
 404for (std::list<string>::iterator it=adj.begin(); it!=adj.end(); ++it)
 405	fmlist.push_back(getIndex(*it));
 406				} 		
 407			}
 408			fmlist.sort();
 409			fmlist.unique();
 410			//fmpdlist.unique(same_int);	
 411			return fmlist; 
 412		}
 413
 414
 415		std::list<int> pdCandidates(int group)
 416		{
 417			std::list<int> pdlist;
 418			//int *pdlist=new int[30];
 419			int k=0;
 420			for(int i = 0; i < vertices.size(); i++)
 421			{
 422				if(vertices[i]->group == 0)
 423				{
 424					//	pdlist[k]=i;
 425					pdlist.push_back(i);
 426					//	k++;		
 427				} 
 428			}
 429			pdlist.sort();
 430			pdlist.unique();
 431			return pdlist; 
 432		}
 433		float Eval(int groupl)
 434		{
 435		float A=0,B=0;
 436		for(int i = 0; i < vertices.size(); i++)
 437                        {
 438			 if(vertices[i]->group == 1)
 439                                {
 440				A=A+vertices[i]->cost;
 441				}
 442			 if(vertices[i]->group == -1)
 443                                {
 444                                B=B+vertices[i]->cost;
 445                                }
 446			}
 447
 448		if(groupl == 1)
 449			{
 450			return A-B;
 451			}
 452		else if(groupl == -1)
 453			{
 454			return B-A;
 455			}
 456	
 457		}
 458		bool gameend()
 459		{
 460		int flag=0;
 461	         for(int i = 0; i < vertices.size(); i++)
 462                        {
 463                                if(vertices[i]->group == 0)
 464                                {
 465				flag=1;
 466                                }
 467                        }
 468		if(flag == 1)
 469			return false;
 470		else
 471			return true;	
 472 		
 473	         	
 474		}
 475		void print_path(int dest=-1,int action=-1,int group=0)
 476		{
 477		static int turn=0;
 478		fprintf(opf,"\nTURN = %d\n",turn);
 479		//cout<<"dest "<<dest<<endl;
 480		if(turn ==0)
 481			{
 482			fprintf(opf,"Player = N/A\n");
 483			fprintf(opf,"Action = N/A\n");
 484			fprintf(opf,"Destination = N/A\n");
 485			}
 486		else
 487			{
 488			if (group==1)
 489			fprintf(opf,"Player =Union\n");
 490			else
 491			fprintf(opf,"Player =Confederacy\n");
 492			if(action ==0)
 493			fprintf(opf,"Action = Force March\n");
 494			else
 495			fprintf(opf,"Action = Paratroop Drop\n");
 496
 497			fprintf(opf,"Destination =%s\n",vertices[dest]->getName().c_str());
 498			}
 499		turn++;
 500		float cost=0;
 501		fprintf(opf,"Union ,{");
 502		 for(int i = 0; i < vertices.size(); i++)
 503                        {
 504                                if(vertices[i]->group == 1)
 505                                {
 506				fprintf(opf,"%s,",vertices[i]->getName().c_str());
 507				cost=cost+vertices[i]->cost;
 508				}
 509			}
 510		fprintf(opf,"},%.1f\n",cost);
 511		cost=0;	
 512		fprintf(opf,"Confederacy ,{");
 513                 for(int i = 0; i < vertices.size(); i++)
 514                        {
 515                                if(vertices[i]->group == -1)
 516                                {
 517				fprintf(opf,"%s,",vertices[i]->getName().c_str());	
 518                               // cout<<vertices[i]->getName();
 519				cost=cost+vertices[i]->cost;	
 520                                }
 521                        }
 522                fprintf(opf,"},%.1f\n",cost);
 523	
 524		fprintf(opf,"---------------------------------\n");	
 525
 526		}
 527		void greedy()
 528		{
 529		int first_step=1;
 530		std::list<int> fm;
 531		std::list<int> pd;
 532		obj ob;
 533		obj temp;
 534		float es=Eval(1);
 535		print_path();
 536			while(1)
 537			{
 538		es=Eval(1);
 539		 priority_queue<obj ,std::vector<obj >,CompareNode > pq;
 540			fm=fmpdCandidates(1);
 541		//cout<<"\nUnion es\t"<<es;
 542		//cout<<"\nfm Candidates";
 543	for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
 544		{
 545				obj ob;
 546				ob.cost=es+vertices[*it]->opponentNeighborCost(-1)+vertices[*it]->cost+vertices[*it]->opponentNeighborCost(-1);
 547				//cout<<"ob cost "<<ob.cost<<endl;
 548				ob.dest=*it;
 549				ob.group=1;
 550				ob.action=0;
 551				if(first_step == 1)
 552					{
 553					print_glog(ob);
 554					}
 555				pq.push(ob);
 556		}
 557
 558
 559				pd=pdCandidates(1);
 560			//cout<<"\npd Candidates";	
 561        for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
 562                {
 563				obj ob;
 564                                ob.cost=es+vertices[*it]->cost;
 565                                ob.dest=*it;
 566                                ob.group=1;
 567                                ob.action=1;
 568				if(first_step == 1)
 569                                        {
 570                                        print_glog(ob);
 571                                        }
 572	
 573				//cout<<"ob=="<<vertices[ob.dest]->getName()<<","<<ob.cost<<endl;
 574                                pq.push(ob);
 575                }
 576	first_step=0;
 577	
 578//	cout<<"\n And the Winner is \n";
 579	temp=pq.top();
 580//	pq.pop();
 581	//cout<<"Dest -->"<<temp.dest<<",action -->"<<temp.cost<<"\t"<<pq.top().cost;
 582
 583	priority_queue<obj ,std::vector<obj >,CompareNode > pq1;
 584	vertices[temp.dest]->group=1;
 585	if(temp.action == 0)
 586		{
 587		vertices[temp.dest]->captureOpponent();
 588		}
 589	 print_path(temp.dest,temp.action,temp.group);			
 590				if(gameend())
 591					break;
 592		es=Eval(-1);
 593		//cout<<"\nConf es"<<es;
 594				fm=fmpdCandidates(-1);
 595
 596 for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
 597                {
 598                                ob.cost=es+vertices[*it]->opponentNeighborCost(1)+vertices[*it]->cost+vertices[*it]->opponentNeighborCost(1);
 599                                ob.dest=*it;
 600                                ob.group=-1;
 601                                ob.action=0;
 602				//cout<<"\nob=="<<vertices[ob.dest]->getName()<<","<<ob.cost<<endl;
 603                                pq1.push(ob);
 604                }
 605
 606
 607
 608				pd=pdCandidates(-1);
 609		for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
 610                {
 611                                ob.cost=es+vertices[*it]->cost;
 612                                ob.dest=*it;
 613                                ob.group=-1;
 614                                ob.action=1;
 615				//cout<<"\nob=="<<vertices[ob.dest]->getName()<<","<<ob.cost<<endl;
 616                                pq1.push(ob);
 617                }
 618
 619
 620		//cout<<"\n And the Winner is \n";
 621        temp=pq1.top();
 622//	pq1.pop();
 623       //cout<<"Dest1 -->"<<temp.dest<<",action -->"<<temp.cost<<"\t"<<pq1.top().cost; 
 624	vertices[temp.dest]->group=-1;
 625        if(temp.action == 0)
 626                {
 627                vertices[temp.dest]->captureOpponent();
 628                }
 629
 630	print_path(temp.dest,temp.action,temp.group);
 631				if(gameend())
 632					break;
 633			}
 634
 635		}
 636
 637obj MaxValue(int vertex,int actionl)
 638            {
 639	obj temp;
 640//print_minmaxlog(vertex,value,actionl);
 641            std::list<int> fm;
 642            std::list<int> pd;
 643            int commitgroup[300];
 644	    static int print_flag=2;
 645
 646            this->depth_terminal++;
 647            //Save State
 648            for(int i=0;i<vertices.size();i++)
 649                {
 650                commitgroup[i]=vertices[i]->group;
 651                }
 652
 653            vertices[vertex]->group=-1;
 654            if(actionl ==0) // Force March? Capture neihbors
 655                {
 656                vertices[vertex]->captureOpponent();
 657                }
 658	  //cout<<"depth_term "<<this->depth_terminal<<"\tterminal "<<terminal<<endl;
 659            if((this->depth_terminal== terminal) || (gameend() ))
 660                {
 661		temp.cost=Eval(1);
 662		//cout<<"\ntemp,cost "<<temp.cost<<endl;
 663		temp.dest=vertex;
 664		temp.action=actionl;
 665		 //resetState();
 666
 667                for(int i=0;i<vertices.size();i++)
 668                        {
 669                        vertices[i]->group=commitgroup[i];
 670                        }
 671
 672		//print_path(temp.dest,temp.action,temp.group);
 673		print_minmaxlog(vertex,temp.cost,actionl,-1,this->depth_terminal);
 674		this->depth_terminal--;
 675                return temp;
 676                }
 677            //Apply the Action//Make Conf Moves 
 678           // saveState();
 679
 680            float value=-65535;
 681
 682          fm=fmpdCandidates(1);
 683          pd=pdCandidates(1);
 684		print_flag=2;
 685//print_minmaxlog(vertex,value,actionl);
 686          for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
 687                {
 688		if(print_flag !=1)
 689			print_minmaxlog(vertex,value,actionl,-1,this->depth_terminal);
 690		print_flag++;
 691                value=max(value,MinValue(*it,0).cost);
 692		print_minmaxlog(vertex,value,actionl,-1,this->depth_terminal);
 693		print_flag=1;
 694                }
 695
 696	for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
 697                {
 698		if(print_flag !=1)
 699			print_minmaxlog(vertex,value,actionl,-1,this->depth_terminal);
 700		print_flag++;
 701                value=max(value,MinValue(*it,1).cost);
 702		print_minmaxlog(vertex,value,actionl,-1,this->depth_terminal);
 703		print_flag=1;
 704                }
 705
 706           //resetState();
 707
 708          for(int i=0;i<vertices.size();i++)
 709              {
 710                vertices[i]->group=commitgroup[i];
 711              }
 712	  temp.cost=value;
 713	this->depth_terminal--;
 714               temp.dest=vertex;
 715                temp.action=actionl;
 716	//print_path(temp.dest,temp.action,temp.group);
 717	//print_minmaxlog(vertex,value,actionl);
 718          return temp;
 719
 720
 721
 722}
 723obj Pruned_MaxValue(int vertex,int actionl,float alpha=-65535,float beta=65535)
 724            {
 725        obj temp;
 726
 727            std::list<int> fm;
 728            std::list<int> pd;
 729            int commitgroup[300];
 730		static int print_flag=2;
 731            this->depth_terminal++;
 732            //Save State
 733            for(int i=0;i<vertices.size();i++)
 734                {
 735                commitgroup[i]=vertices[i]->group;
 736                }
 737
 738            vertices[vertex]->group=-1;
 739            if(actionl ==0) // Force March? Capture neihbors
 740                {
 741                vertices[vertex]->captureOpponent();
 742                }
 743          //cout<<"depth_term "<<this->depth_terminal<<"\tterminal "<<terminal<<endl;
 744            if((this->depth_terminal== terminal) || (gameend() ))
 745                {
 746                temp.cost=Eval(1);
 747                temp.dest=vertex;
 748                temp.action=actionl;
 749		temp.alpha=alpha;
 750		temp.beta=beta;
 751                 //resetState();
 752
 753                for(int i=0;i<vertices.size();i++)
 754                        {
 755                        vertices[i]->group=commitgroup[i];
 756                        }
 757
 758                //print_path(temp.dest,temp.action,temp.group);
 759
 760		print_prunedlog(temp.dest,temp.cost,actionl,-1,this->depth_terminal,alpha,beta);
 761		this->depth_terminal--;
 762
 763                return temp;
 764                }
 765            //Apply the Action//Make Conf Moves 
 766           // saveState();
 767	 float value=-65535;
 768
 769          fm=fmpdCandidates(1);
 770          pd=pdCandidates(1);
 771		print_flag=2;
 772          for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
 773                {
 774	if(print_flag != 1)
 775		print_prunedlog(vertex,value,actionl,-1,this->depth_terminal,alpha,beta);
 776	print_flag++;
 777                value=max(value,Pruned_MinValue(*it,0,alpha,beta).cost);
 778		 alpha=max(alpha,value);
 779                temp.alpha=alpha;
 780                temp.beta=beta;
 781
 782		if(value >= beta)
 783			{
 784			temp.cost=value;
 785               		temp.dest=vertex;
 786                	temp.action=actionl;
 787			for(int i=0;i<vertices.size();i++)
 788              			{
 789                		vertices[i]->group=commitgroup[i];
 790              			}
 791			cout<<"\nCut-off";
 792			print_prunedlog(temp.dest,temp.cost,actionl,-1,this->depth_terminal,alpha,beta,1);
 793			this->depth_terminal--;
 794			temp.alpha=alpha;
 795                	temp.beta=beta;
 796
 797			return temp;
 798
 799			}
 800	//	alpha=max(alpha,value);
 801	//	temp.alpha=alpha;
 802         //       temp.beta=beta;
 803		print_prunedlog(vertex,value,actionl,-1,this->depth_terminal,alpha,beta);
 804		print_flag=1;
 805                }
 806
 807
 808        for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
 809                {
 810		if(print_flag !=1)
 811		print_prunedlog(vertex,value,actionl,-1,this->depth_terminal,alpha,beta);
 812		
 813		print_flag++;
 814                value=max(value,Pruned_MinValue(*it,1,alpha,beta).cost);
 815		alpha=max(alpha,value);
 816                temp.alpha=alpha;
 817                temp.beta=beta;
 818
 819		if(value >= beta)
 820			{
 821			temp.cost=value;
 822			temp.dest=vertex;
 823		print_prunedlog(temp.dest,temp.cost,actionl,-1,this->depth_terminal,alpha,beta,1);
 824                        this->depth_terminal--;
 825                        temp.action=actionl;
 826			for(int i=0;i<vertices.size();i++)
 827                                {
 828                                vertices[i]->group=commitgroup[i];
 829                                }
 830			temp.alpha=alpha;
 831                        temp.beta=beta;
 832
 833
 834                        return temp;
 835			}
 836		
 837               // alpha=max(alpha,value);
 838	//	temp.alpha=alpha;
 839         //       temp.beta=beta;
 840		print_prunedlog(vertex,value,actionl,-1,this->depth_terminal,alpha,beta);
 841		print_flag=1;
 842                }
 843
 844           //resetState();
 845
 846          for(int i=0;i<vertices.size();i++)
 847              {
 848                vertices[i]->group=commitgroup[i];
 849              }
 850          temp.cost=value;
 851        this->depth_terminal--;
 852               temp.dest=vertex;
 853                temp.action=actionl;
 854	temp.alpha=alpha;
 855        temp.beta=beta;
 856
 857        //print_path(temp.dest,temp.action,temp.group);
 858          return temp;
 859
 860}
 861
 862	    obj MinValue(int vertex,int actionl)
 863	    {
 864	obj temp;
 865	    
 866            std::list<int> fm;
 867            std::list<int> pd;
 868	    int commitgroup[300];
 869		static int print_flag=2;
 870
 871	    this->depth_terminal++;
 872	    //Save State
 873	    for(int i=0;i<vertices.size();i++)
 874		{
 875		commitgroup[i]=vertices[i]->group;
 876		}
 877
 878            vertices[vertex]->group=1;
 879	    if(actionl ==0) // Force March? Capture neihbors
 880		{
 881		vertices[vertex]->captureOpponent();
 882		}
 883	    //cout<<"depth_term "<<this->depth_terminal<<"\tterminal "<<terminal<<endl;
 884	    if((this->depth_terminal== terminal) || (gameend() ))
 885		{
 886		temp.cost=Eval(1);
 887		//cout<<"\ntemp.cost "<<temp.cost<<endl;
 888		//this->depth_terminal--;
 889		 //resetState();
 890
 891          	for(int i=0;i<vertices.size();i++)
 892              		{
 893                	vertices[i]->group=commitgroup[i];
 894              		}
 895                temp.dest=vertex;
 896                temp.action=actionl;
 897		//print_path(temp.dest,temp.action,temp.group);
 898
 899		print_minmaxlog(vertex,temp.cost,actionl,1,this->depth_terminal);
 900		this->depth_terminal--;
 901		return temp;		
 902		}
 903	    //Apply the Action//Make Conf Moves 
 904	   // saveState();
 905	   
 906	   float value=65535;
 907	//print_minmaxlog(vertex,value,actionl);
 908	  fm=fmpdCandidates(-1);
 909	  pd=pdCandidates(-1);
 910	print_flag=2;
 911	  for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
 912                {
 913		if(print_flag != 1)
 914			print_minmaxlog(vertex,value,actionl,1,this->depth_terminal);
 915		print_flag++;
 916		value=min(value,MaxValue(*it,0).cost);
 917		print_minmaxlog(vertex,value,actionl,1,this->depth_terminal);
 918		print_flag=1;
 919		}
 920	
 921
 922	  for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
 923                {
 924		if(print_flag != 1)
 925			print_minmaxlog(vertex,value,actionl,1,this->depth_terminal);
 926		print_flag++;
 927		//cout<<"\nvalue "<<value<<endl;
 928		value=min(value,MaxValue(*it,1).cost);
 929		//cout<<"\nvalue "<<value<<endl;
 930		print_minmaxlog(vertex,value,actionl,1,this->depth_terminal);
 931		print_flag=1;
 932		}
 933
 934	
 935	   //resetState();
 936	   
 937	  for(int i=0;i<vertices.size();i++)
 938              {
 939                vertices[i]->group=commitgroup[i];
 940              }
 941	temp.cost=value;
 942	this->depth_terminal--;
 943                temp.dest=vertex;
 944                temp.action=actionl;
 945	//print_path(temp.dest,temp.action,temp.group);
 946//	print_minmaxlog(vertex,value,actionl);
 947	  return temp;	
 948
 949	    }
 950	 obj Pruned_MinValue(int vertex,int actionl,float alpha,float beta)
 951            {
 952        obj temp;
 953            std::list<int> fm;
 954            std::list<int> pd;
 955            int commitgroup[300];
 956		static int print_flag=2;
 957            this->depth_terminal++;
 958            //Save State
 959            for(int i=0;i<vertices.size();i++)
 960                {
 961                commitgroup[i]=vertices[i]->group;
 962                }
 963
 964            vertices[vertex]->group=1;
 965            if(actionl ==0) // Force March? Capture neihbors
 966                {
 967                vertices[vertex]->captureOpponent();
 968                }
 969            //cout<<"depth_term "<<this->depth_terminal<<"\tterminal "<<terminal<<endl;
 970            if((this->depth_terminal== terminal) || (gameend() ))
 971                {
 972                temp.cost=Eval(1);
 973		print_prunedlog(vertex,temp.cost,actionl,1,this->depth_terminal,alpha,beta);
 974                //this->depth_terminal--;
 975                 //resetState();
 976
 977                for(int i=0;i<vertices.size();i++)
 978                        {
 979                        vertices[i]->group=commitgroup[i];
 980                        }
 981                temp.dest=vertex;
 982                temp.action=actionl;
 983		if((this->alpha_stat<temp.cost) && (this->depth_terminal == 1))
 984			{
 985			this->alpha_stat=temp.cost;
 986			}
 987		this->depth_terminal--;
 988		temp.alpha=alpha;
 989                temp.beta=beta;
 990
 991                //print_path(temp.dest,temp.action,temp.group);
 992                return temp;
 993                }
 994            //Apply the Action//Make Conf Moves 
 995           // saveState();
 996
 997            float value=65535;
 998	  fm=fmpdCandidates(-1);
 999          pd=pdCandidates(-1);
1000	
1001	  print_flag=2;
1002
1003          for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
1004                {
1005		if(print_flag !=1)
1006		print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta);
1007	
1008		print_flag++;	
1009                value=min(value,Pruned_MaxValue(*it,0,alpha,beta).cost);
1010		beta=min(beta,value);
1011		temp.alpha=alpha;
1012                temp.beta=beta;
1013
1014		if(value<=alpha)
1015			{
1016			 for(int i=0;i<vertices.size();i++)
1017		              {
1018               			 vertices[i]->group=commitgroup[i];
1019              		      }
1020			if((this->alpha_stat<value)&&((this->depth_terminal == 1)))
1021                        {
1022                       // this->alpha_stat=value;
1023                        }
1024
1025        		temp.cost=value;
1026			print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta,1);
1027        		this->depth_terminal--;
1028                	temp.dest=vertex;
1029                	temp.action=actionl;
1030
1031
1032			return temp;
1033			}
1034	//	beta=min(beta,value);
1035		if((this->alpha_stat<value) &&(this->depth_terminal == 1))
1036                        {
1037                        this->alpha_stat=value;
1038                        }
1039
1040		print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta);
1041		print_flag=1;
1042                }
1043
1044
1045          for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
1046                {
1047		if(print_flag !=1)
1048		  print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta);
1049		print_flag++;
1050                value=min(value,Pruned_MaxValue(*it,1,alpha,beta).cost);
1051		beta=min(beta,value);
1052		temp.alpha=alpha;
1053                temp.beta=beta;
1054	
1055		if(value<=alpha)
1056			 {
1057                         for(int i=0;i<vertices.size();i++)
1058                              {
1059                                 vertices[i]->group=commitgroup[i];
1060                              } 
1061
1062			if((this->alpha_stat<value)&&(this->depth_terminal == 1))
1063                        {
1064                        //this->alpha_stat=value;
1065                        }
1066
1067                        temp.cost=value;
1068			print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta,1);
1069                        this->depth_terminal--;
1070                        temp.dest=vertex;
1071                        temp.action=actionl;
1072			temp.alpha=alpha;
1073                        temp.beta=beta;
1074
1075                        return temp;
1076                        }
1077
1078               // beta=min(beta,value);
1079		if((this->alpha_stat<value)&&(this->depth_terminal == 1))
1080                        {
1081                        this->alpha_stat=value;
1082                        }
1083
1084		print_prunedlog(vertex,value,actionl,1,this->depth_terminal,alpha,beta);
1085		print_flag=1;
1086                }
1087
1088           //resetState();
1089
1090          for(int i=0;i<vertices.size();i++)
1091              {
1092                vertices[i]->group=commitgroup[i];
1093              }
1094        temp.cost=value;
1095        this->depth_terminal--;
1096                temp.dest=vertex;
1097                temp.action=actionl;
1098		temp.alpha=alpha;
1099                temp.beta=beta;
1100
1101        //print_path(temp.dest,temp.action,temp.group);
1102          return temp;
1103
1104        }
1105
1106            //Returns obj with Vertex Number
1107	    obj greedy_move()
1108	    {
1109
1110		std::list<int> fm;
1111                std::list<int> pd;
1112                obj ob;
1113                obj temp;
1114                 
1115                priority_queue<obj ,std::vector<obj >,CompareNode > pq1;
1116
1117
1118		float es=Eval(-1);
1119	
1120                //cout<<"\nConf es"<<es;
1121                                fm=fmpdCandidates(-1);
1122
1123 for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
1124                {
1125                                ob.cost=es+vertices[*it]->opponentNeighborCost(1)+vertices[*it]->cost+vertices[*it]->opponentNeighborCost(1);
1126                                ob.dest=*it;
1127                                ob.group=-1;
1128                                ob.action=0;
1129                                //cout<<"\nob=="<<vertices[ob.dest]->getName()<<","<<ob.cost<<endl;
1130                                pq1.push(ob);
1131                }
1132
1133
1134
1135                                pd=pdCandidates(-1);
1136                for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
1137                {
1138                                ob.cost=es+vertices[*it]->cost;
1139                                ob.dest=*it;
1140                                ob.group=-1;
1141                                ob.action=1;
1142                                //cout<<"\nob=="<<vertices[ob.dest]->getName()<<","<<ob.cost<<endl;
1143                                pq1.push(ob);
1144                }
1145
1146
1147                //cout<<"\n And the Winner is \n";
1148        temp=pq1.top();
1149//      pq1.pop();
1150       //cout<<"Dest1 -->"<<temp.dest<<",action -->"<<temp.cost<<"\t"<<pq1.top().cost; 
1151        vertices[temp.dest]->group=-1;
1152        if(temp.action == 0)
1153                {
1154                vertices[temp.dest]->captureOpponent();
1155                }
1156	
1157	return temp;
1158
1159	    }
1160	    //Return obj with Vertex Number
1161	    obj Minimax_move()
1162	    {
1163	     //For all candidates of union return Max(MinValue())
1164		std::list<int> fm;
1165                std::list<int> pd;
1166		obj max;
1167		float cost=-65535;
1168		static int print_flag=2;
1169		std::list<obj> templist;
1170		obj temp;
1171		temp.group=1;
1172		temp.cost=-65535;
1173		max.cost=-65535;	
1174		fm=fmpdCandidates(1);
1175		print_flag=2;
1176		for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
1177                {
1178		this->depth_terminal=0;
1179		if(print_flag != 1)
1180			print_minmaxlog(-1,cost);
1181		print_flag++;
1182		temp=MinValue(*it,0);//pass Vertex number
1183		temp.action=0;
1184		templist.push_back(temp);
1185		if(cost<temp.cost)
1186			cost=temp.cost;
1187		print_minmaxlog(-1,cost);
1188		print_flag=1;	
1189		}
1190		
1191		pd=pdCandidates(1);
1192		for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
1193                {
1194		this->depth_terminal=0;
1195		if(print_flag != 1)
1196			print_minmaxlog(-1,cost);
1197		print_flag++;
1198		temp=MinValue(*it,1);//pass Vertex number
1199		temp.action=1;
1200                templist.push_back(temp);
1201		if(cost<temp.cost)
1202                        cost=temp.cost;
1203
1204		print_minmaxlog(-1,cost);
1205		print_flag=1;
1206		}
1207	   //Find the Max in templist and return it 
1208    for (std::list<obj>::iterator it=templist.begin(); it!=templist.end(); ++it)
1209                {
1210		if(max.cost <(*it).cost)
1211		   {
1212			//cout<<"\n*itcost "<<(*it).cost;
1213		   max.cost=(*it).cost;
1214		   max=*it;
1215		   }
1216		
1217		}
1218
1219
1220	 vertices[max.dest]->group=1;
1221        if(max.action == 0)
1222                {
1223                vertices[max.dest]->captureOpponent();
1224                }
1225	max.group=1;
1226	global_turn++;
1227	 return max;
1228
1229	    
1230	    }
1231
1232	obj Pruned_Minimax_move()
1233            {
1234             //For all candidates of union return Max(MinValue())
1235                std::list<int> fm;
1236                std::list<int> pd;
1237                obj max;
1238		static int print_flag=2;
1239		print_flag=2;	
1240                std::list<obj> templist;
1241                obj temp;
1242		float max_alpha=-65535;
1243                temp.group=1;
1244                max.cost=-65535;
1245		//temp.alpha=-65535;
1246		//temp.beta=65535;
1247                fm=fmpdCandidates(1);
1248		static int i=1;
1249		i=1;
1250
1251                for (std::list<int>::iterator it=fm.begin(); it!=fm.end(); ++it)
1252                {
1253                this->depth_terminal=0;
1254		if(i==1)
1255			{
1256			print_prunedlog(-1,-65535,-1,-1,0,-65535,65535);
1257
1258			temp=Pruned_MinValue(*it,0,-65535,65535);//pass Vertex number
1259			i++;
1260			}
1261		else
1262			{
1263			if(max_alpha<temp.cost)
1264				max_alpha=temp.cost;
1265			if(print_flag != 1)
1266				print_prunedlog(-1,max_alpha,-1,-1,0,max_alpha,65535);
1267			print_flag++;
1268                	temp=Pruned_MinValue(*it,0,max_alpha,65535);//pass Vertex number
1269			if(max_alpha<temp.cost)
1270                                max_alpha=temp.cost;
1271
1272			print_prunedlog(-1,max_alpha,-1,-1,0,max_alpha,65535);
1273			print_flag=1;
1274			//cout<<"\ncoss "<<temp.cost<<endl;
1275			}
1276                temp.action=0;
1277                templist.push_back(temp);
1278                }
1279
1280                pd=pdCandidates(1);
1281                for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
1282                {
1283                this->depth_terminal=0;
1284		if(i==1)
1285                        {
1286                          print_prunedlog(-1,max_alpha,-1,-1,0,max_alpha,65535);
1287	
1288                        temp=Pruned_MinValue(*it,1,-65535,65535);//pass Vertex number
1289                       i++; 
1290                        }
1291                else
1292                        {
1293			if(max_alpha<temp.cost)
1294                                max_alpha=temp.cost;
1295			if(print_flag != 1)
1296                                print_prunedlog(-1,max_alpha,-1,-1,0,max_alpha,65535);
1297			print_flag++;
1298                        temp=Pruned_MinValue(*it,1,max_alpha,65535);//pass Vertex number
1299			if(max_alpha<temp.cost)
1300                                max_alpha=temp.cost;
1301			print_prunedlog(-1,max_alpha,-1,-1,0,max_alpha,65535);
1302			print_flag=1;
1303                        }
1304
1305                temp.action=1;
1306                templist.push_back(temp);
1307
1308                }
1309           //Find the Max in templist and return it 
1310    for (std::list<obj>::iterator it=templist.begin(); it!=templist.end(); ++it)
1311                {
1312                if(max.cost <(*it).cost)
1313                   {
1314                        cout<<"\n*itcost "<<(*it).cost;
1315                   max.cost=(*it).cost;
1316                   max=*it;
1317                   }
1318
1319                }
1320
1321	 vertices[max.dest]->group=1;
1322        if(max.action == 0)
1323                {
1324                vertices[max.dest]->captureOpponent();
1325                }
1326        max.group=1;
1327	global_turn++;
1328         return max;
1329
1330	}
1331		
1332	    //Alternates between Minimax move and greedy move
1333	    void Minimax_game()
1334	    {
1335	   print_path();
1336	    while(1)
1337	    	{
1338	    	obj Union=Minimax_move();
1339		//vertices[Union.dest]->group=1;
1340		if(gameend())
1341		 break;	
1342		cout<<"\nChecking Minimax move == max"<<Union.cost<<"\n";
1343		print_path(Union.dest,Union.action,Union.group);
1344	    	obj Conf=greedy_move();
1345		//vertices[Conf.dest]->group=-1;
1346		print_path(Conf.dest,Conf.action,Conf.group);	
1347		if(gameend())
1348		 break;	
1349	    	}
1350
1351	    }
1352	void Pruned_game()
1353	{
1354	 print_path();
1355            while(1)
1356                {
1357                obj Union=Pruned_Minimax_move();
1358                //vertices[Union.dest]->group=1;
1359                if(gameend())
1360                 break;
1361                cout<<"\nChecking Minimax move == max"<<Union.cost<<"\n";
1362                print_path(Union.dest,Union.action,Union.group);
1363                obj Conf=greedy_move();
1364                //vertices[Conf.dest]->group=-1;
1365                print_path(Conf.dest,Conf.action,Conf.group);
1366                if(gameend())
1367                 break;
1368                }
1369
1370	}
1371	   
1372		int terminal;
1373	private:
1374		vector<Vertex*> vertices;
1375		int depth_terminal;
1376		int alpha_stat;
1377};
1378
1379main(int argc,char *argv[])
1380{
1381
1382
1383int task;
1384int depth;
1385char mapname[50];
1386char initmap[50];
1387char outputpath[100];
1388char outputlog[100];
1389
1390
1391if(argc!=13)
1392	{
1393	cout<<"Please enter valid Arguments\nUsage :\n";
1394	cout<<"war -t <task> -d < cut_off_depth> -m<map_file> -i <init > -op <output_path> -ol <output_log>"<<endl;
1395	exit(1);
1396	}
1397else
1398     {
1399	task=atoi(argv[2]);
1400	depth=atoi(argv[4]);
1401	strcpy(mapname,argv[6]);
1402	strcpy(initmap,argv[8]);
1403	strcpy(outputpath,argv[10]);
1404	strcpy(outputlog,argv[12]);
1405
1406	}
1407
1408
1409
1410
1411	char source[300],dest[300],cost[300],group[300],node[300];
1412	string line;
1413	int edge_count=0,node_count=0;
1414	int i=0;
1415	int j=0;
1416	int k=0,k1=0;
1417	char *source_arr[100];
1418	char *dest_arr[100];
1419	char *nodes[100];
1420	float cost_arr[100];
1421	int group_arr[100];
1422
1423
1424
1425
1426	//char *ranker[100];
1427	map<string,bool> check;
1428	ifstream myfile (mapname);
1429	if (myfile.is_open())
1430	{
1431		while ( getline (myfile,line) )
1432		{
1433			memset(source,0,300);
1434			memset(dest,0,300);
1435			i=0;
1436			j=0;
1437			//cout << line << "\n";
1438			while (line[i] != ',')
1439			{
1440				source[j]=line[i];
1441				i++;
1442				j++;
1443			}
1444			i++;
1445			j=0;
1446			while(line[i]>= 'A'&&line[i]<='z')
1447			{
1448				dest[j]=line[i];
1449				i++;
1450				j++;
1451			}
1452			//nncout<<"\n"<<dest<<","<<j<<endl;
1453			source_arr[k]=new char[300];
1454			dest_arr[k]=new char[300];
1455			strcpy(source_arr[k],source);
1456			strcpy(dest_arr[k],dest); 
1457			k++;
1458		}
1459		myfile.close();
1460	}
1461	edge_count=k;
1462	k=0;
1463	for(int temp=0;temp<edge_count;temp++)
1464	{
1465		//cout<<source_arr[temp]<<"-->"<<dest_arr[temp]<<endl;
1466	}
1467	ifstream myfile1(initmap);
1468	if (myfile1.is_open())
1469	{
1470		while ( getline (myfile1,line) )
1471		{
1472			memset(node,0,300);
1473			memset(cost,0,300);	
1474			memset(group,0,300);
1475			i=0;
1476			j=0;
1477
1478			//cout << line << "\n";
1479			while (line[i] != ',')
1480			{
1481				node[j]=line[i];
1482				i++;
1483				j++;
1484			}
1485			i++;
1486			j=0;
1487			while (line[i] != ',')
1488			{
1489				cost[j]=line[i];
1490				i++;
1491				j++;
1492			}
1493			i++;
1494			j=0;
1495			while (line[i] !='\0')
1496			{
1497				group[j]=line[i];
1498				i++;
1499				j++;
1500			}
1501			nodes[k]=new char[300];
1502			strcpy(nodes[k],node);
1503			cost_arr[k]=atof(cost); 
1504			group_arr[k]=atoi(group);
1505			k++;		
1506		}
1507		myfile1.close();
1508	}
1509
1510	node_count=k;
1511	for(int temp1=0;temp1<node_count;temp1++)
1512	{
1513		//cout<<nodes[temp1]<<","<<cost_arr[temp1]<<","<<group_arr[temp1]<<endl;
1514	}
1515
1516	Vertex *v[100];
1517	int source_ind=0,dest_ind=0;
1518	for(int cur=0;cur<node_count;cur++)
1519	{
1520		v[cur]=new Vertex(nodes[cur],cost_arr[cur],group_arr[cur]);
1521		cout<<"Vertex"<<v[cur]->name<<","<<v[cur]->group<<","<<v[cur]->cost<<endl;
1522	}
1523
1524	for(int cur=0;cur<node_count;cur++)
1525	{
1526		for(int cur1=0;cur1<edge_count;cur1++)
1527		{	
1528			if(v[cur]->name==source_arr[cur1])
1529			{
1530				for(int i = 0; i < node_count; i++)
1531				{
1532					//cout<<"\n1"<<v[i]->name<<","<<dest_arr[cur1]<<endl;
1533					if(v[i]->name ==dest_arr[cur1])
1534					{
1535						//			cout<<"\n2";
1536						v[cur]->addEdge(v[i]);
1537						v[i]->addEdge(v[cur]);
1538					}
1539				}
1540
1541
1542			}
1543		}
1544
1545
1546
1547	}
1548
1549
1550opf=fopen(outputpath,"w");
1551opl=fopen(outputlog,"w");
1552
1553
1554	Graph g1;
1555	g1.terminal=depth;
1556	for(int cur=0;cur<node_count;cur++)
1557	{
1558		g1.insert(v[cur]);
1559	}
1560	g1.printGraph();
1561/*	std::list<int> fmpd=g1.fmpdCandidates(-1);
1562
1563	std::cout << "fmlist contains:";
1564	for (std::list<int>::iterator it=fmpd.begin(); it!=fmpd.end(); ++it)
1565		std::cout << ' ' << *it;
1566	std::cout << '\n';
1567
1568	std::list<int> pd=g1.pdCandidates(-1);
1569
1570	std::cout << "pdlist contains:";
1571	for (std::list<int>::iterator it=pd.begin(); it!=pd.end(); ++it)
1572		std::cout << ' ' << *it;*/
1573	std::cout << '\n';
1574
1575	if(task ==1)
1576		{
1577		g1.greedy();
1578		}
1579	else if(task ==3)
1580		{
1581		g1.Pruned_game();
1582		}
1583	else if(task == 2)
1584		{
1585		g1.Minimax_game();
1586		}
1587
1588
1589}