public DraughtsSummary(DraughtsState draughtsState) { foreach (System.Drawing.Point place in draughtsState.Board.PlacesAndNeighbors.Keys) { if (draughtsState.Board[place] != null) { Results[draughtsState.Board[place].Value]++; } } byte max = Results.Values.Max(); if (!Results.All(a => a.Value == max)) { Winner = Results.First(a => a.Value == max).Key; } }
protected IDictionary <ResultKey, TResult> MakeChromInfoResultsMap <TChromInfo, TResult>( Results <TChromInfo> results, Func <ResultFile, TResult> newResultFunc) where TChromInfo : ChromInfo { if (results == null) { return(ImmutableSortedList <ResultKey, TResult> .EMPTY.AsDictionary()); } var replicates = DataSchema.ReplicateList; var resultFiles = DataSchema.ResultFileList; if (replicates.Count == results.Count && results.All(r => r.Count == 1 && r[0] != null)) { // If every replicate has exactly one result, then we can reuse the keys in "DataSchema.ReplicateList". var newValues = new List <TResult>(replicates.Count); for (int replicateIndex = 0; replicateIndex < replicates.Count; replicateIndex++) { var chromInfo = results[replicateIndex][0]; var optStep = ResultFile.GetOptStep(chromInfo); ResultFile resultFile = null; if (optStep == 0) { resultFiles.TryGetValue(new ResultFileKey(replicateIndex, chromInfo.FileId, optStep), out resultFile); } if (resultFile == null) { resultFile = new ResultFile(replicates.Values[replicateIndex], chromInfo.FileId, optStep); } newValues.Add(newResultFunc(resultFile)); } return(replicates.ReplaceValues(newValues).AsDictionary()); } var newEntries = new List <KeyValuePair <ResultKey, TResult> >(); for (int replicateIndex = 0; replicateIndex < results.Count; replicateIndex++) { var replicate = new Replicate(DataSchema, replicateIndex); var files = results[replicateIndex]; for (int fileIndex = 0; fileIndex < files.Count; fileIndex++) { var chromInfo = files[fileIndex]; if (null == chromInfo) { continue; } var key = fileIndex == 0 ? replicates.Keys[replicateIndex] : new ResultKey(replicate, fileIndex); int optStep = ResultFile.GetOptStep(chromInfo); ResultFile resultFile = null; if (optStep == 0) { resultFiles.TryGetValue(new ResultFileKey(replicateIndex, chromInfo.FileId, optStep), out resultFile); } if (resultFile == null) { resultFile = new ResultFile(replicates.Values[replicateIndex], chromInfo.FileId, optStep); } newEntries.Add(new KeyValuePair <ResultKey, TResult>(key, newResultFunc(resultFile))); } } return(ImmutableSortedList <ResultKey, TResult> .FromValues(newEntries, Comparer <ResultKey> .Default) .AsDictionary()); }
public bool IsValid() { return(Results.All(x => x.ProductId.IsValid())); }
private ResultType ResolveType() => Results.All(r => r.Type == ResultType.Success) ? ResultType.Success : ResultType.Failed;