Closed rokbok closed 11 months ago
I encountered the same problem. Here is a minimal code snippet to reproduce behavior, if you play b1a3, a1b1, b1a1, a1b1 b1a1 it does the trick.
using ChessChallenge.API;
using System;
public class MyBot : IChessBot
{
int[] pieceValues = { 0, 100, 300, 300, 500, 900, 10000 };
public Move Think(Board board, Timer timer)
{
bool a = board.IsDraw();
Move moveToPlay = ThinkHarder(board, board.IsWhiteToMove);
bool b = board.IsDraw();
if (a != b) // log if weirdness happen
{
Console.WriteLine(board.GetFenString());
Console.WriteLine(moveToPlay);
Console.WriteLine(board.IsInStalemate());
Console.WriteLine(board.IsRepeatedPosition());
Console.WriteLine(board.IsInsufficientMaterial());
Console.WriteLine(board.IsFiftyMoveDraw());
}
return moveToPlay;
}
Move ThinkHarder(Board board, bool color)
{
Move[] allMoves = board.GetLegalMoves();
Move moveToPlay = allMoves[0];
foreach (Move move in allMoves)
{
board.MakeMove(move);
board.UndoMove(move);
}
return moveToPlay;
}
}
Thank you, I've fixed the bug with the depth counter. Sorry about that!
Absolutely no worries and thank you for the fix
Board.depth
is increased inMakeMove
, but not decreased inUndoMove
. This leads to issues, at the very least in the following situationIsDraw()
returnsfalse
IsDraw()
returnstrue
, because the checkdepth > 0
inIsRepeatedPosition
returnstrue
, when it returnedfalse
the first time around.This could be related to #170. The reason I created a separate bug is that it is not clear that this is the only cause for #170.