public WinnerManager(WinnerList live, CandidateWinners candidates, WinnerList final, int finalistCount) { this.Live = live; this.Candidates = candidates; this.Final = final; this.FinalistCount = finalistCount; }
private static void ExtractHistory(out SortedList <string, ShipDNA> filenames, out SortedList <string, double> filenameScores, WinnerList winners) { #region Check for no winners if (winners == null) { filenames = null; filenameScores = null; return; } var dump = winners.Current; if (dump == null || dump.Length == 0) { filenames = null; filenameScores = null; return; } #endregion filenames = new SortedList <string, ShipDNA>(); filenameScores = new SortedList <string, double>(); List <string> dupeCheck = new List <string>(); foreach (var set in dump) { // Escape the filename string shipname = EscapeFilename(set.ShipName); if (dupeCheck.Contains(shipname.ToUpper())) { shipname += Guid.NewGuid().ToString(); } dupeCheck.Add(shipname.ToUpper()); foreach (var lineage in set.BeansByLineage) { for (int cntr = 0; cntr < lineage.Item2.Length; cntr++) { // Name - Lineage - Rank.xml string filename = string.Format("{0} - {1} - {2}.xml", shipname, EscapeFilename(lineage.Item1), cntr.ToString()); // there won't be a dupe on lineage, it's just a guid // One or the other will be nonnull if (lineage.Item2[cntr].Ship != null) { filenames.Add(filename, lineage.Item2[cntr].Ship.GetNewDNA()); } else { filenames.Add(filename, lineage.Item2[cntr].DNA); } // Store the score (it's a separate list so that it can be directly serialized) filenameScores.Add(filename, lineage.Item2[cntr].Score); } } } }
private void RefreshStatsSprtDump(ReportLineType lineType, WinnerList.WinningSet[] dump) { if (dump == null || dump.Length == 0) { return; } //NOTE: dump is already sorted by highest score foreach (var row in dump) { // Get maxes for each lineage string[] heights = new string[row.BeansByLineage.Length]; string[] gens = new string[heights.Length]; for (int cntr = 0; cntr < heights.Length; cntr++) { heights[cntr] = Math.Round(row.BeansByLineage[cntr].Item2.Max(o => o.Score), 1).ToString(); gens[cntr] = row.BeansByLineage[cntr].Item2.Max(o => o.Ship != null ? o.Ship.Generation : o.DNA.Generation).ToString(); } // There's no need to show the lineage name, it's just a guid RefreshStatsSprtAddRow(lineType, row.ShipName, string.Join("\r\n", heights), string.Join("\r\n", gens)); } }
private Tuple<long, WinnerList.WinningBean>[] UpdateFinalistScores(WinnerList.WinningBean[] scores, long[] removedTokens) { // Update the scores foreach (var score in scores) { long token = score.Ship.PhysicsBody.Token; if (_livingFinalistTopScores.ContainsKey(token)) { if (score.Score > _livingFinalistTopScores[token].Score) { _livingFinalistTopScores[token] = score; // only keeping the highest score achieved } } else { _livingFinalistTopScores.Add(token, score); // add for the first time } } // Remove any that are now dead List<Tuple<long, WinnerList.WinningBean>> retVal = new List<Tuple<long, WinnerList.WinningBean>>(); foreach (long dead in removedTokens) { if (_livingFinalistTopScores.ContainsKey(dead)) { retVal.Add(Tuple.Create(dead, _livingFinalistTopScores[dead])); _livingFinalistTopScores.Remove(dead); } } // Exit Function return retVal.ToArray(); }
public void RefreshWinners(WinnerList.WinningBean[] liveScores, WinnerList.WinningBean[] liveCandidateScores) { // Get the remove tokens long[] removedTokens = _removedTokens.ToArray(); _removedTokens.Clear(); // Refresh the live list var winningLiveRemovals = this.Live.StoreWinners(liveScores, removedTokens); // Refresh the finalist scores var candidateRemovals = UpdateFinalistScores(liveCandidateScores, removedTokens); // Of the ships that died, track candidates (not all dead ships will be tracked in candidates) TransitionToCandidates(winningLiveRemovals, candidateRemovals, removedTokens); // Look for candidates that are finished being tested, and see if they are good enough to be stored in the final list TransitionToFinal(); }
public WinnerManager(WinnerList live, CandidateWinners candidates, WinnerList final, int finalistCount) { this.Live = live; this.Candidates = candidates; this.Final = final; this.FinalistCount = finalistCount; }