To setup the chess game, following have to be done:
Here is simple example of textual chess game implementation:
#include <tartan/chess.hpp>
#include "tartan/board/exceptions.hpp"
#include <iostream>
#include <string>
int main() {
while (not board.currentKing()->checkmate()) {
do {
try {
continue;
}
try {
board.makeTurn(from, to);
continue;
}
}
return 0;
}
void fill()
Fills current Board with default pieces.
Definition board.cpp:166
Piece position at the Board.
Definition board.hpp:36
Chess game board.
Definition chess.hpp:22
Base class for all tartan exceptions.
Definition exceptions.hpp:18
Here are more complex TUI chess game implementation:
#include <tartan/chess.hpp>
#include "tartan/board/exceptions.hpp"
#include <iostream>
#include <string>
void cls(void);
int main() {
while (not board.currentKing()->checkmate()) {
do {
std::cout <<
"Enter valid move: ____\b\b\b\b";
try {
std::cout <<
"Error: 'from' position is invalid: "
continue;
}
try {
std::cout <<
"Error: 'to' position is invalid: "
continue;
}
try {
board.makeTurn(from, to);
print_exception(ex);
continue;
}
cls();
}
(board.currentKing()->color() == tt::Piece::Color::White ?
"White" : "Black") << " king is under checkmate.\n";
return 0;
}
void cls(void) {
for (int i = 0; i < 100; i++)
}
"exception: " << e.
what() <<
'\n';
try {
print_exception(e, level+1);
} catch(...) {}
}
T rethrow_if_nested(T... args)