diff --git a/Chess-Challenge/src/My Bot/MyBot.cs b/Chess-Challenge/src/My Bot/MyBot.cs index a565840fc..7535caeef 100644 --- a/Chess-Challenge/src/My Bot/MyBot.cs +++ b/Chess-Challenge/src/My Bot/MyBot.cs @@ -1,4 +1,4 @@ -using ChessChallenge.API; +using ChessChallenge.API; using System; public class MyBot : IChessBot @@ -28,23 +28,23 @@ public MyBot() public Move ThinkInternal(Board board, Timer timer, int maxDepth = 50, bool report = true) #else - public Move Think(Board board, Timer timer) + public Move Think(Board board, ChessChallenge.API.Timer timer) #endif { Move bestMoveRoot = default; var killers = new Move[128]; - + int maxTime = timer.MillisecondsRemaining / 30, iterDepth = 1; #if UCI nodes = 0; for (int depth = 0; ++depth <= maxDepth && timer.MillisecondsElapsedThisTurn < timer.MillisecondsRemaining / 30;) #else - for (int depth = 0; ++depth <= 50 && timer.MillisecondsElapsedThisTurn < timer.MillisecondsRemaining / 30;) + while (timer.MillisecondsElapsedThisTurn < maxTime) #endif { #if UCI int score = #endif - Search(-30000, 30000, depth, 0); + Search(-30000, 30000, iterDepth++, 0); #if UCI if (report && timer.MillisecondsElapsedThisTurn < timer.MillisecondsRemaining / 30) { @@ -104,7 +104,7 @@ int Search(int alpha, int beta, int depth, int ply) foreach (Move move in moves) { - if (timer.MillisecondsElapsedThisTurn >= timer.MillisecondsRemaining / 10) + if (timer.MillisecondsElapsedThisTurn >= maxTime * 2) return 30000; board.MakeMove(move); @@ -116,7 +116,8 @@ int Search(int alpha, int beta, int depth, int ply) alpha = score; hashMove = move; if (ply == 0) bestMoveRoot = move; - if (alpha >= beta) { + if (alpha >= beta) + { if (!move.IsCapture) killers[ply] = move; break;