/// <summary> /// Make the FML picks for a miner (both with bonus and without) /// </summary> /// <param name="miner">The miner to adjust the picks.</param> private void MakePicks(IMiner miner) { if (miner.Movies != null && miner.Movies.Any()) { // Need to clone the list otherwise the above MovieList will lose its BestPerformer. var clonedList = new List <IMovie>(); foreach (var movie in miner.Movies.Where(item => item.Earnings > 0)) { clonedList.Add(movie.Clone()); } // TODO: This needs to be an injected prototype. IMoviePicker moviePicker = new MsfMovieSolver(); moviePicker.AddMovies(clonedList); miner.Picks = moviePicker.ChooseBest(); clonedList.Clear(); foreach (var movie in miner.Movies.Where(item => item.Earnings > 0)) { clonedList.Add(movie.Clone()); } moviePicker.AddMovies(clonedList); moviePicker.EnableBestPerformer = false; miner.PicksBonusOff = moviePicker.ChooseBest(); } }
public void MinerModelSimulation_OneStepUpDown() { Dictionary <int, int> bestListCounts = new Dictionary <int, int>(); // Keyed using the hash code. Dictionary <int, IMovieList> bestLists = new Dictionary <int, IMovieList>(); // Keyed using the hash code. ElapsedTime elapsed = new ElapsedTime(); var moviePicker = new MsfMovieSolver { DisplayDebugMessage = false }; var builder = new StringBuilder(); var test = new MinerModel(true, null, null); var defaultWeights = CreateDefaultWeights(); var weights = GenerateWeightLists(new List <int>(), defaultWeights); //foreach (var list in weights) //{ // foreach (var weight in list) // { // builder.Append(weight); // } // builder.Append("\r"); //} //Debug.Write(builder); foreach (var list in weights) { SetWeights(test, list); moviePicker.AddMovies(test.CreateWeightedList()); var best = moviePicker.ChooseBest(); var hashCode = best.GetHashCode(); int value; // Increment (or add to) the best list counts if (bestListCounts.TryGetValue(hashCode, out value)) { bestListCounts[hashCode] = value + 1; } else { bestListCounts.Add(hashCode, 1); bestLists.Add(hashCode, best); } } // Sort through the MOST times a list is counted. foreach (var item in bestListCounts.OrderByDescending(item => item.Value).Take(5)) { Debug.WriteLine($"Number of votes: {bestListCounts[item.Key]}/{weights.Count}"); WriteMovies(bestLists[item.Key]); } }