SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

board.MakeMove is giving an issue even tho it gets its moves from GetLegalMoves #438

Closed JoelSjoberg123 closed 1 year ago

JoelSjoberg123 commented 1 year ago
    int Search(Board board, Move move, Timer timer, int iterations, bool myTurn)
    {

    //This is the only place where Make- and UndoMove are used right now

    board.MakeMove(move);

    Move[] moves = board.GetLegalMoves();

    //call itself and evaluate

    board.UndoMove(move);
    return bestScore;
    }
dogbreaf commented 1 year ago

Make sure you aren't exiting the search function before undoing the move, e.g. if you are cheking for mate in one and returning that move before doing the rest of the evaluation and then undoing the move

JoelSjoberg123 commented 1 year ago

That was close, but it wasn't in the checmate stuff. It was something else in the evaluate where I forgot to undomove.