SebLague / Chess-Challenge

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

How to use TrySkipTurn / UndoSkipTurn #422

Closed artm closed 11 months ago

artm commented 11 months ago

I have attempted to use them to count legal turns / threats by the opponent like:

        if (board.TrySkipTurn()){
            // their mobility/threats will only be deducted when we're not in
            // check, but when we are our mobility is mostly decreased anyway
            score -= board.GetLegalMoves().Length + board.GetLegalMoves(true).Length;
            board.UndoSkipTurn();
        }

this mostly seems to work except once in a while my bot now attempts to make an illegal move elsewhere in the code. Am I using it wrong?

I'll be testing my bot without this fragment now, to find out if it was in fact this code that caused to bot to get confused.

artm commented 11 months ago

My bot has just made an illegal move with this fragment commented out, I guess this wasn't the culprit.