stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
utils_ui.hpp (991B)
0 #ifndef STELLAR_UTILS_UI_HPP
1 #define STELLAR_UTILS_UI_HPP
3 #include <string>
5 #include "utils.hpp"
7 /* Color */
9 static const std::string to_string(const Color color) {
10 return std::string(color == WHITE ? "white" : "black");
11 }
13 /* Square */
15 static const char *coordinates_array[] = {
16 // clang-format off
17 "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
18 "a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
19 "a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3",
20 "a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4",
21 "a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5",
22 "a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6",
23 "a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7",
24 "a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8", " "
25 // clang-format on
26 };
28 static const std::string to_coordinates(const Square square) { return coordinates_array[square]; }
30 static Square from_coordinates(const std::string &cord) {
31 return static_cast<Square>((cord[1] - '1') * 8 + (cord[0] - 'a'));
32 }
34 #endif