-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathengichess.cpp
More file actions
72 lines (66 loc) · 1.67 KB
/
engichess.cpp
File metadata and controls
72 lines (66 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<iostream>
#include<string>
#include<stdlib.h>
#include<iomanip>
#include<windows.h>
#include<math.h>
#include<conio.h>
#include "board.h"
#include "eval.h"
#include "gametree.h"
#define GAMEDEPTH 2
int main (void)
{
Board obj1;
int move=0;
Evaluation obj2;
string passd;
bool turn=1;
cout<<"\n\nWelcome To EngiChess\n\nEnter Moves in string fashion Eg <a1b7>\nEnter x to Exit.\n\n";
obj1.printboard();
int ct=0;
while(obj1.EndGame==false&& obj1.get_EndGame()==false)
{ if(turn)
{ /*obj1=nextmove(obj1,GAMEDEPTH);
obj1.printboard();
//_getch();
turn=0;
ct++;
*/
cout<<endl<<"Enter Move:";
cin>>passd;
if (passd.substr(0, 1) >= "a" && passd.substr(0, 1) <= "h" && passd.substr(1, 1) >= "1" && passd.substr(1, 1) <= "8" && passd.substr(2, 1) >= "a" && passd.substr(2, 1) <= "h" && passd.substr(3, 1) >= "1" && passd.substr(3, 1) <= "8")
{ int a,b,c,d;
a = passd[0] - 'a';
b = passd[1] - '1';
c = passd[2] - 'a';
d = passd[3] - '1';
if(obj1.checkvalid((b*8)+a,(d*8)+c)==0)
{ cout<<"This move is Illegal"<<endl;
obj1.printboard();
}
else
{ obj1.makemove((b*8)+a,(d*8)+c);
cout<<"\nScore:"<<obj2.EvaluateBoardScore(obj1);
obj1.printboard();
getch();
turn=0;
ct++;
}
}
if(passd.substr(0,1)=="x")
break;
}
if(!turn)
{ obj1=nextmove(obj1,GAMEDEPTH);
cout<<"\nScore:"<<obj2.EvaluateBoardScore(obj1);
obj1.printboard();
move=move+2;
//cout<<"\nMove: "<<move;
turn=1;
ct++;
}
obj1.findBlackMateOrCheck();
obj1.findWhiteMateOrCheck();
}
}