private ResultDetails PlayMatch(Dictionary <Player, IAIAlgorithm> algorithms, int matchNumber, Action <int> updateTurn) { var board = new CheckerBoard(); board.InitializeBoard(); Stopwatch matchStopwatch = new Stopwatch(); Stopwatch stopwatch = new Stopwatch(); int turns = 0; matchStopwatch.Start(); while (board.GetGameStatus() == GameStatuses.Running) { updateTurn(turns); stopwatch.Reset(); stopwatch.Start(); var move = algorithms[board.NextPlayer].GetMove(board, board.NextPlayer); stopwatch.Stop(); if (move == null) { return(new ResultDetails(MatchResult.NoMoreMoves, matchStopwatch.Elapsed, turns)); } Console.WriteLine($"\tTurn #{matchNumber}.{turns}; Player {board.NextPlayer}; ({move.piece1.Row}, {move.piece1.Column}) to ({move.piece2.Row}, {move.piece2.Column}); Elapsed: {stopwatch.ElapsedMilliseconds} ms"); board.MakeMove(move, board.NextPlayer); if (board.GetGameStatus() != GameStatuses.Running) { var result = board.GetGameStatus(); if (result == GameStatuses.RedWon) { return(new ResultDetails(MatchResult.RedWon, matchStopwatch.Elapsed, algorithms[board.NextPlayer].GetType(), turns)); } else if (result == GameStatuses.BlackWon) { return(new ResultDetails(MatchResult.BlackWon, matchStopwatch.Elapsed, algorithms[board.NextPlayer].GetType(), turns)); } else { throw new Exception($"Unsupported result: {result}"); } } if (++turns >= this.MaxTurnsPerMatch) { return(new ResultDetails(MatchResult.MaxTurnsReached, matchStopwatch.Elapsed, turns)); } } return(new ResultDetails(MatchResult.NoResult, matchStopwatch.Elapsed, turns)); }