SebLague / Chess-Challenge

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

IsDraw() is never returning true when a position is a draw #400

Closed loki12241224 closed 1 year ago

loki12241224 commented 1 year ago

`public Move Think(Board board, Timer timer) { isWhite = board.IsWhiteToMove; Tuple<Move, float> BestMove = MiniMax(board, 4, -100000, 100000, true); Console.WriteLine("ChosenMove: " + BestMove); Console.WriteLine("-=-=-=-=-=-=-=-=-=-=-"); board.MakeMove(BestMove.Item1); if (board.IsDraw()) { System.Threading.Thread.Sleep(1000000); }

    return BestMove.Item1;
}`

this never sleeps when a drawing position occurs. i cannot get IsDraw() to return true.

mcthouacbb commented 1 year ago

If the position is a draw then the think function won't be called because the game is already over

LooveToLoose commented 1 year ago

There is a board.MakeMove before the Draw check, though, so it should go off if the next move results in a draw, right? Same issue here.

My guess would be that the problem might have something to do with the MiniMax search? Maybe if a piece is taken the repetition table is cleared but not reinstantiated when the move is undone? Something like that?

SebLague commented 1 year ago

This should be fixed in the latest version, sorry about that!

tom-anders commented 1 year ago

thank you so much, I kept wondering which commit would suddenly make my AI draw all the time - guess i should just use git pull instead of git pull --rebase next time

loki12241224 commented 1 year ago

The newest update to the file seems to have fixed the issue.