示例#1
0
        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));
//            }
        }
示例#2
0
 public bool HasAnyFinished()
 {
     return(SpeciesAndValues.Any(pair => pair.Value.Result >= 10000));
 }