public void UpdateStrategies(IEnumerable <Strategy> strategies) { Stopwatch sw = new Stopwatch(); sw.Start(); ConcurrentDictionary <Strategy, FightStat> tempDictionary = new ConcurrentDictionary <Strategy, FightStat>(); Parallel.ForEach(strategies, strategy => { tempDictionary.TryAdd(strategy, Evaluator.countFitness(strategy)); }); foreach (var pair in tempDictionary) { SpeciesAndValues.AddOrUpdate(pair.Key, pair.Value); } log.Info($"Parallel update strategies: {sw.ElapsedMilliseconds}"); sw.Reset(); // foreach (var strategy in strategies) // { // SpeciesAndValues.AddOrUpdate(strategy, Evaluator.countFitness(strategy)); // } }
public bool HasAnyFinished() { return(SpeciesAndValues.Any(pair => pair.Value.Result >= 10000)); }