From 51d27e1ab9058c9e0fafb399e22edf7b38470510 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 27 Jul 2026 20:14:54 +0200 Subject: adding uci --- src/moves.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/moves.cpp') diff --git a/src/moves.cpp b/src/moves.cpp index 9c7991a..5401e8b 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -6,7 +6,7 @@ #include "board.hpp" #include "moves.hpp" -void GenerateKnightMoves(Board *b, int from, std::vector &moves) { +void GenerateKnightMoves(Game *b, int from, std::vector &moves) { Piece knight = b->pieces[from]; if (knight.type != KNIGHT) { @@ -34,7 +34,7 @@ void GenerateKnightMoves(Board *b, int from, std::vector &moves) { moves.push_back({IndexToPosition(from), IndexToPosition(next)}); } }; -void GeneratePawnMoves(Board *b, int from, std::vector &moves) { +void GeneratePawnMoves(Game *b, int from, std::vector &moves) { Piece pawn = b->pieces[from]; if (pawn.type != PAWN) { assert(false && "Calling generate pawn moves on non pawn"); @@ -83,7 +83,7 @@ void GeneratePawnMoves(Board *b, int from, std::vector &moves) { // the end } -std::vector GetPseudoLegalMoves(Board *b) { +std::vector GetPseudoLegalMoves(Game *b) { std::vector moves; moves.reserve(50); // almost all position dont have that many moves @@ -123,12 +123,12 @@ std::vector GetPseudoLegalMoves(Board *b) { return moves; } -std::vector GetLegalMoves(Board *b) { +std::vector GetLegalMoves(Game *b) { std::vector moves = GetPseudoLegalMoves(b); std::vector legalMove; for (Move move : moves) { bool isLegal = true; - Board testBoard = *b; + Game testBoard = *b; PlayMove(move, &testBoard); auto opponentResponse = GetPseudoLegalMoves(&testBoard); for (Move move : opponentResponse) { @@ -143,7 +143,7 @@ std::vector GetLegalMoves(Board *b) { if (legalMove.size() == 0) { bool isCheck = false; - Board testBoard = *b; + Game testBoard = *b; auto opponentResponse = GetPseudoLegalMoves(&testBoard); for (Move move : opponentResponse) { if (testBoard.pieces[PositionToIndex(move.To)].type == KING) { @@ -170,7 +170,7 @@ Position IndexToPosition(int i) { return {rank, file}; } -void GenerateSlidingMoves(Board *b, int from, +void GenerateSlidingMoves(Game *b, int from, const std::array &directions, std::vector &moves) { for (uint i = 0; i < directions.size(); i++) { @@ -205,7 +205,7 @@ void GenerateSlidingMoves(Board *b, int from, }; }; -void GenerateKingMoves(Board *b, int from, std::vector &moves) { +void GenerateKingMoves(Game *b, int from, std::vector &moves) { if (b->pieces[from].type != KING) { assert(false && "calling generate king moves on non king"); return; -- cgit v1.2.3