Fix occasional crash on bot timeout during match

This commit is contained in:
Sebastian Lague 2023-07-23 19:40:34 +02:00
parent cc3f49319b
commit 1d2368295c

View file

@ -23,6 +23,7 @@ namespace ChessChallenge.Application
}
// Game state
Random rng;
int gameID;
bool isPlaying;
Board board;
@ -60,6 +61,7 @@ namespace ChessChallenge.Application
tokenCount = GetTokenCount();
Warmer.Warm();
rng = new Random();
moveGenerator = new();
boardUI = new BoardUI();
board = new Board();
@ -77,7 +79,7 @@ namespace ChessChallenge.Application
{
// End any ongoing game
EndGame(GameResult.DrawByArbiter, log: false, autoStartNextBotMatch: false);
gameID++;
gameID = rng.Next();
// Stop prev task and create a new one
if (RunBotsOnSeparateThread)
@ -275,6 +277,7 @@ namespace ChessChallenge.Application
{
isPlaying = false;
isWaitingToPlayMove = false;
gameID = -1;
if (log)
{