-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.h
116 lines (114 loc) · 4.74 KB
/
global.h
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
#include <iostream>
#include<tuple>
#include "Board.h"
#define inverse(P) for(int ii = 0; ii <= 7; ii++){for (int j = 0; j <= 7; j++){P[ii][j] = P[ii][j] * -1;}}
#define RED "\033[31m"
#define BLUE "\033[1;34m"
#define PURPLE "\033[1;35m"
#define RESET "\033[0m"
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
int P[8][8] = {
{-1, -1, -1, -1, -1, -1, -1, -1,},
{-1, -1, -1, -1, -1, -1, -1, -1,},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1} };
inline bool valid(int x, int y)
{
if ((x >= 0) && (y >= 0) && (x <= 7) && (y <= 7))
return true;
else
return false;
}
inline int** inv()
{
int** Pc = new int* [8];
for (int i = 0; i < 8; i++)
Pc[i] = new int[8];
for (int i = 0; i <= 7; i++)
{
for (int j = 0; j <= 7; j++)
{
Pc[i][j] = (P[i][j]) * -1;
}
}
return Pc;
}
std::tuple<int_pair, int_pair> Extract(string str)
{
try
{
std::string x = str.substr(0, 2);
std::string y = str.substr(6, 2);
char x1 = x[0];
char x2 = x[1];
char y1 = y[0];
char y2 = y[1];
int_pair ip1 = std::make_pair((int)x1 - '0', (int)(x2 - 96));
int_pair ip2 = std::make_pair((int)y1 - '0', (int)(y2 - 96));
return std::make_tuple(ip1, ip2);
}
catch (const std::out_of_range& oor)
{
std::cerr << RED<<"\t\t\t\tError: Try again\n"<<RESET;
int_pair ip1 = std::make_pair(-1,-1);
int_pair ip2 = std::make_pair(-1,-1);
return std::make_tuple(ip1, ip2);
}
}
void display_header()
{
std::cout << "*********************************************************************" << std::endl;
std::cout << "* _()_ *" <<
std::endl << "* _/____\\_ *" <<
std::endl << "* \\ / _ _ _ *" <<
std::endl << "* \\____/ | || || | *" <<
std::endl << "* (____) |_______| *" <<
std::endl << "* | | \\__ ___ / *" <<
std::endl << "* |__| _ |___|_| *" <<
std::endl << "* / \\ ___| |__ ___ ___ ___ |_|___| *" <<
std::endl << "* (______) / __| '_ \\ / _ \\/ __/ __| |___|_| *" <<
std::endl << "* (________) | (__| | | | __/\\__ \\__ \\ (_______) *" <<
std::endl << "* /________\\ \\___|_| |_|\\___||___/___/ /_______\\ *" << std::endl;
std::cout << std::endl << "*********************************************************************" << std::endl;
}
void welcome()
{
std::cout
<< " ,....,\n"
<< " ,::::::< ___ ___ ___ ______ _____ ________ __ \n"
<< " ,::/^\\\"``. | \\/ | / _ \\| _ \\ ___| | ___ \\ \\ / / _\n"
<< " ,::/, ` e`. | . . |/ /_\\ \\ | | | |__ | |_/ /\\ V / (_) \n"
<< " ,::; | '. | |\\/| || _ | | | | __| | ___ \\ \\ / \n"
<< " ,::| \\___,-. c) | | | || | | | |/ /| |___ | |_/ / | | _ \n"
<< " ;::| \\ '-' \\_| |_/\\_| |_/___/ \\____/ \\____/ \\_/ (_) \n"
<< " ;::| \\ \n"
<< " ;::| _.=`\\ \n"
<< " `;:|.=` _.=`\\ _____ _____ ___ ___ ___ ___ ___ ___ _ _ ___________ _____ \n"
<< " '|_.=` __\\ | _ / ___|/ _ \\ | \\/ | / _ \\ | \\/ || | | |_ _| ___ \\_ _|\n"
<< " `\\_..==`` / | | | \\ `--./ /_\\ \\| . . |/ /_\\ \\ | . . || |_| | | | | |_/ / | | \n"
<< " .'.___.-'. | | | |`--. \\ _ || |\\/| || _ | | |\\/| || _ | | | | / | | \n"
<< " / \\ \\ \\_/ /\\__/ / | | || | | || | | | | | | || | | |_| |_| |\\ \\ _| |_ \n"
<< " ('--......--') \\___/\\____/\\_| |_/\\_| |_/\\_| |_/ \\_| |_/\\_| |_/\\___/\\_| \\_|\\___/ \n"
<< " /'--......--'\\ \n"
<< " `\"--......--\" \n";
}
int_pair help(string str)
{
std::string x = str.substr(5, 2);
char x1 = x[0];
char x2 = x[1];
return std::make_pair((int)x1 - '0', (int)(x2 - 96));
}
bool inline seek_help(string str)
{
std::string x = str.substr(0, 4);
if (x == "help")
return true;
else
return false;
}