blob: 4b9e9659f4d4a0afa68fb08579895c9f16126b9b (
plain)
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
|
#include "board.hpp"
#include "fen.hpp"
#include "repl.hpp"
#include <cstdio>
#include <iostream>
#include <print>
#include <string>
using namespace std;
enum Mode {
EXIT,
REPL,
};
void setAllPiecesToEmpty(Board *b) {
Piece EmptyPiece = {
false,
NONE,
false,
};
for (int i = 0; i < 64; i++) {
b->pieces[i] = EmptyPiece;
};
};
Board initBoard(string startingFEN) {
Board b;
b.turn = true;
b.castle = "";
b.halfMoveClock = 0;
b.MoveClock = 0;
setBoardFen(startingFEN, &b);
return b;
};
int main(int argc, char **argv) {
std::string startingFen =
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
if (argc < 1 || argc > 2) {
printf("wrong arg count, use: ./chess [optinal starting fen]\n");
return 1;
}
printf("arg count: %d\n", argc);
if (argc == 2) {
startingFen = argv[1];
}
println("ENTER which mode you want (REPL)");
Mode mode = EXIT;
string modeString;
cin >> modeString;
std::transform(modeString.begin(), modeString.end(), modeString.begin(),
::toupper);
if (modeString == "REPL") {
mode = REPL;
}
// ADD support for other modes here
Board b = initBoard(startingFen);
if (mode == REPL) {
int replExitCode = startREPL(&b);
return replExitCode;
}
if (mode == EXIT) {
return 0;
}
return 0;
}
|