From 3760828b8fab504e2fbfe9a8eb1d39a821b3982a Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 25 Jul 2026 14:45:04 +0200 Subject: adding fen as optinal argument --- src/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index f958d11..fa4b3a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include "board.hpp" @@ -8,7 +10,17 @@ Piece NonePiece = { false, }; -int main() { +int main(int argc, char **argv) { + printf("arg count: %d", argc); + 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]"); + return 1; + } + if (argc == 2) { + startingFen = argv[1]; + } board b; b.turn = true; b.castle = ""; @@ -17,7 +29,7 @@ int main() { for (int i = 0; i < 64; i++) { b.pieces[i] = NonePiece; }; - setBoardFen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", &b); + setBoardFen(startingFen, &b); printBoard(&b); return EXIT_SUCCESS; } -- cgit v1.2.3