private async Task <int> InternalRun(CancellationToken cancellationToken) { LogInfoHeader(); if (Options == null) { throw new ArgumentNullException(nameof(Options), "Cannot be null"); } Game.Table.SetSize(TranspositionTableOptions.Size); var runnerIndex = (Options is FenOptions).ToInt(); _usingEpd = runnerIndex == 0; var positions = _runners[runnerIndex].Invoke(cancellationToken); _perft.Positions = new List <IPerftPosition>(); await foreach (var position in positions.WithCancellation(cancellationToken)) { _perft.AddPosition(position); var result = await ComputePerft(cancellationToken).ConfigureAwait(false); } return(0); }
private async Task <int> InternalRun(CancellationToken cancellationToken = default) { LogInfoHeader(); if (Options == null) { throw new ArgumentNullException(nameof(Options), "Cannot be null"); } if (TranspositionTableOptions.Use) { Game.Table.SetSize(TranspositionTableOptions.Size); } var errors = 0; var runnerIndex = (Options is FenOptions).ToInt(); _usingEpd = runnerIndex == 0; var positions = _runners[runnerIndex].Invoke(cancellationToken); _perft.Positions = new List <IPerftPosition>(); await foreach (var position in positions.WithCancellation(cancellationToken).ConfigureAwait(false)) { _perft.AddPosition(position); try { var result = await ComputePerft(cancellationToken).ConfigureAwait(false); errors = result.Errors; if (errors != 0) { _log.Error("Parsing failed for Id={0}", position.Id); } _resultPool.Return(result); } catch (AggregateException e) { _log.Error(e.GetBaseException(), "Cancel requested."); errors = 1; break; } } return(errors); }