private void addToNextGenForFollowUp(RunItem <PositionData, ActionData, CheckPointType> item)
        {
            //var category = PositionCategorizer.Categorize(item.Position);

            var area = AreaGuide.PositionAreaId(item.Position.Data);

            //item.PreSolution.CategoryPath.Add(category);
            item.Position.CategoryPath.Add(area);

            if (item.HasMoved && !Fingerprints.ContainsKey(item.Position.Data.Fingerprint) && !(Targets.All(t => t.ReachTarget(item.Position) || t.IsOptional) && CancelCriteria == CancelCriteria.TargetsReached) && !(CancelCriteria == CancelCriteria.MaxSteps && item.Position.Depth >= TargetOptCenterParams.MaxSearchDepth))
            {
                //item.Score = item.Position.Data.NextCheckPoint.Score(item.Position.Data);
                item.PreSolution.Score = AreaGuide.Score(item.Position.Data) + random.NextDouble() * 0.00001;

                var nextGen = CheckPoints.FirstOrDefault(ng => ng.CategoryNr == area);
                if (nextGen == null)
                {
                    nextGen            = new LocalCheckPoint();
                    nextGen.CategoryNr = area;
                    CheckPoints.Add(nextGen);
                }

                //if (nextGen.Positions.All(rI => AreaGuide.CanOvercome(item.Position.Data, rI.Position.Data)))
                {
                    nextGen.Positions.SortedInsert(item.PreSolution, TargetOptCenterParams.NextGenerationSize, (c) => c.Score);
                    Fingerprints.Add(item.Position.Data.Fingerprint, item);
                }
            }
            else
            {
            }
        }
示例#2
0
        public RunItem <PositionData, ActionData, CheckPointType> Breed(RunItem <PositionData, ActionData, CheckPointType> item2)
        {
            var weights = new double[Weights.Length];

            for (int i = 0; i < weights.Length; i++)
            {
                var witem1 = GrundWelt.Program.Random.NextDouble();
                weights[i] = witem1 * Weights[i] + (1 - witem1) * item2.Weights[i] * (1.0 + GrundWelt.Program.Random.NextDouble() * 0.2 - 0.1);
            }

            var child = new RunItem <PositionData, ActionData, CheckPointType>(null, OnTargetReached, ActionHandling, weights, MultiEvaluationOptions);

            return(child);
        }
示例#3
0
        public void Load()
        {
            try
            {
                foreach (var file in Directory.GetFiles(StoragePath))
                {
                    using (var reader = new StreamReader(file))
                    {
                        var item = RunItem <PositionData, ActionData, CheckPointType> .Load(reader, DefaultActionHandling, MultiEvaluationOptions);

                        item.OnTargetReached = OnEndpositionDiscovered;
                        volatilePopulation.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Post("error loading RunItems for Pool " + Id + ". - " + e.Message, LogCategory.Inconsistency);
            }
        }
示例#4
0
        internal static RunItem <PositionData, ActionData, CheckPointType> Load(StreamReader reader, ActionHandling <PositionData, ActionData> actionHandling, int multiEvaluationOptions)
        {
            var id   = int.Parse(reader.ReadLine().Substring(4));
            var gold = double.Parse(reader.ReadLine().Substring(6));

            reader.ReadLine(); //weights
            var line    = "";
            var weights = new List <double>();

            while ((line = reader.ReadLine()).NotNullOrEmpty())
            {
                weights.Add(double.Parse(line));
            }
            var item = new RunItem <PositionData, ActionData, CheckPointType>(null, null, actionHandling, weights.ToArray(), multiEvaluationOptions);

            item.Id   = id;
            item.Gold = gold;

            return(item);
        }
 public static void AssignPreSolution <PositionData, ActionData, CheckpointData>(this RunItem <PositionData, ActionData, CheckpointData> champ, PreSolution <PositionData, ActionData, CheckpointData> solution)
     where PositionData : BasePositionData <PositionData, ActionData, CheckpointData>, Cloneable <PositionData>, IHasFingerprint
     where ActionData : BaseActionData <PositionData, ActionData, CheckpointData>
     where CheckpointData : CheckPoint <PositionData>
 {
     solution.RunItemPath.Add(champ);
     champ.PreSolutions.Add(solution);
 }