aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 5be119469f9ac83ecedcee5c2be2f6009dd59d98 (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
#include <cstdio>
#include <cstdlib>
#include <string>

#include "board.hpp"
#include "moves.hpp"

Piece NonePiece = {
    false,
    NONE,
    false,
};
#include <iostream>

void PrintMoves(const std::vector<Move> &moves) {
  std::cout << "Moves (" << moves.size() << "):\n";

  for (const Move &move : moves) {
    std::cout << "(" << (int)move.From.file << ", " << (int)move.From.rank
              << ") -> (" << (int)move.To.file << ", " << (int)move.To.rank
              << ")\n";
  }
}
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];
  }
  board b;
  b.turn = true;
  b.castle = "";
  b.halfMoveClock = 0;
  b.MoveClock = 0;
  for (int i = 0; i < 64; i++) {
    b.pieces[i] = NonePiece;
  };
  setBoardFen(startingFen, &b);
  printBoard(&b);
  auto moves = GetLegalMoves(&b);
  PrintMoves(moves);
  return EXIT_SUCCESS;
}