-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (40 loc) · 681 Bytes
/
main.cpp
File metadata and controls
42 lines (40 loc) · 681 Bytes
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
#include <iostream>
#include <cstdio>
#include "chess.hpp"
using namespace std;
int main () {
Chess ch;
for (;;) {
ch.print();
char str[10];
scanf("%s", str);
int x1,y1,x2,y2;
x1 = str[0]-'a';
y1 = str[1]-'1';
x2 = str[2]-'a';
y2 = str[3]-'1';
if (ch.move(make_pair(x1,y1),make_pair(x2,y2))) {
printf("Successful!\n");
} else {
printf("Illegal!\n");
}
switch (ch.board.query_state()) {
case 0:
printf("Ongoing.\n");
break;
case 1:
printf("Black wins!\n");
break;
case 2:
printf("Drawn!\n");
break;
case 3:
printf("White wins!\n");
break;
default:
printf("Wut.\n");
break;
}
}
return 0;
}