private IScpWorkflow UpdateGenomesStepH(int seed)
        {
            var successfulEvals = SorterLayerEval.GenomeEvals
                                  .Where(ev => ev.Success)
                                  .OrderBy(e => e.Score)
                                  .ToList();
            var legacyCount   = 0;
            var cubCount      = 0;
            var leftoverCount = 0;
            var leftoverTotal = ScpParams.PopulationCount - ScpParams.CubCount - ScpParams.LegacyCount;
            //var newGenomes = new List<ISorterGenome>();
            var newGenomes = new Dictionary <string, ISorterGenome>();



            foreach (var evaluatedGenome in successfulEvals)
            {
                var sorterStages = CompPool.SorterEval(evaluatedGenome.Guid)
                                   .Reduce(Guid.NewGuid()).ToStagedSorter()
                                   .SorterStages
                                   .ToList();

                //var hash = evaluatedGenome.Score + " " +
                //sorterStages.Repeat().Skip((Generation / 5) % sorterStages.Count).Take(5)
                //    .Select(s=>s.KeyPairs.Select(kp=>kp.Index)
                //                         .Aggregate(string.Empty, (str,i) => str + "," + i)
                //           )
                //    .Aggregate(string.Empty, (st,i) => st + (String.IsNullOrEmpty(st) ? "" : ",") + i);


                var hash = evaluatedGenome.Score + " " +
                           sorterStages
                           .Take(5)
                           .Select(s => s.KeyPairs.Select(kp => kp.Index)
                                   .Aggregate(string.Empty, (str, i) => str + "," + i)
                                   )
                           .Aggregate(string.Empty, (st, i) => st + (String.IsNullOrEmpty(st) ? "" : ",") + i);


                if (newGenomes.ContainsKey(hash))
                {
                    continue;
                }

                if (
                    SorterLayer0.GetGenome(evaluatedGenome.Guid) != null
                    &&
                    legacyCount < ScpParams.LegacyCount
                    )
                {
                    newGenomes[hash] = evaluatedGenome.Genome;
                    legacyCount++;
                }

                else if (
                    SorterLayer1.GetGenome(evaluatedGenome.Guid) != null
                    &&
                    cubCount < ScpParams.CubCount
                    )
                {
                    newGenomes[hash] = evaluatedGenome.Genome;
                    cubCount++;
                }
                else if (leftoverCount < leftoverTotal)
                {
                    newGenomes[hash] = evaluatedGenome.Genome;
                    leftoverCount++;

                    if (SorterLayer0.GetGenome(evaluatedGenome.Guid) != null)
                    {
                        legacyCount++;
                    }
                    else
                    {
                        cubCount++;
                    }
                }
            }

            return(new ScpWorkflowImpl
                   (
                       compWorkflowState: CompWorkflowState.ReproGenomes,
                       sorterLayer0: Layer.Make(
                           generation: Generation + 1,
                           genomes: newGenomes.Values
                           ),
                       sorterLayer1: null,
                       compPool: CompPool.TrimEvalsToTheseIds(newGenomes.Select(g => g.Value.Guid)),
                       sorterLayerEval: newGenomes.Select(g => SorterLayerEval.GetGenomeEval(g.Value.Guid))
                       .Make <ISorterGenome, IGenomeEval <ISorterGenome> >(),
                       scpParams: ScpParams,
                       generation: Generation + 1,
                       report: JsonConvert.SerializeObject(new Tuple <int, int>(legacyCount, cubCount), Formatting.None)
                   ));
        }
        private IScpWorkflow UpdateGenomesStep(int seed)
        {
            var successfulEvals = SorterLayerEval.GenomeEvals
                                  .Where(ev => ev.Success)
                                  .SubSortShuffle(e => e.Score, seed)
                                  .ToList();
            var legacyCount   = 0;
            var cubCount      = 0;
            var leftoverCount = 0;
            var leftoverTotal = ScpParams.PopulationCount - ScpParams.CubCount - ScpParams.LegacyCount;
            var newGenomes    = new List <ISorterGenome>();


            foreach (var evaluatedGenome in successfulEvals)
            {
                if (
                    SorterLayer0.GetGenome(evaluatedGenome.Guid) != null
                    &&
                    legacyCount < ScpParams.LegacyCount
                    )
                {
                    newGenomes.Add(evaluatedGenome.Genome);
                    legacyCount++;
                }

                else if (
                    SorterLayer1.GetGenome(evaluatedGenome.Guid) != null
                    &&
                    cubCount < ScpParams.CubCount
                    )
                {
                    newGenomes.Add(evaluatedGenome.Genome);
                    cubCount++;
                }
                else if (leftoverCount < leftoverTotal)
                {
                    newGenomes.Add(evaluatedGenome.Genome);
                    leftoverCount++;

                    if (SorterLayer0.GetGenome(evaluatedGenome.Guid) != null)
                    {
                        legacyCount++;
                    }
                    else
                    {
                        cubCount++;
                    }
                }
            }

            return(new ScpWorkflowImpl
                   (
                       compWorkflowState: CompWorkflowState.ReproGenomes,
                       sorterLayer0: Layer.Make(
                           generation: Generation + 1,
                           genomes: newGenomes
                           ),
                       sorterLayer1: null,
                       compPool: CompPool.TrimEvalsToTheseIds(newGenomes.Select(g => g.Guid)),
                       sorterLayerEval: newGenomes.Select(g => SorterLayerEval.GetGenomeEval(g.Guid))
                       .Make <ISorterGenome, IGenomeEval <ISorterGenome> >(),
                       scpParams: ScpParams,
                       generation: Generation + 1,
                       report: JsonConvert.SerializeObject(new Tuple <int, int>(legacyCount, cubCount), Formatting.None)
                   ));
        }