Example #1
0
        public RunnerPool(ActionHandling <PositionData, ActionData> defaultActionHandling, int multiEvaluationOptions, int id = 0, int basicPopulation = GlobalParameters.RunnerPoolDefaultBasicPopulation)
        {
            MultiEvaluationOptions = multiEvaluationOptions;
            Id = id.ToString();
            if (id == 0)
            {
                Id = Program.Random.Next().ToString();
            }

            StoragePath += Id + "//";

            DefaultActionHandling = defaultActionHandling;
            BasicPopulation       = basicPopulation;


            Load();
        }
Example #2
0
        public RunItem(GWPosition <PositionData, ActionData> position, Action <RunItem <PositionData, ActionData, CheckPointType> > onTargetReached, ActionHandling <PositionData, ActionData> actionHandling, double[] weights, int multiEvaluationOptions)
        {
            MultiEvaluationOptions = multiEvaluationOptions;
            Id = Program.Random.Next();
            OnTargetReached = onTargetReached;
            ActionHandling  = actionHandling;
            Weights         = weights;
            if (Weights == null)
            {
                Weights = new double[actionHandling.ActionEvaluators.Count()];

                for (int i = 0; i < actionHandling.ActionEvaluators.Count(); i++)
                {
                    Weights[i] = Program.Random.NextDouble();
                }
            }

            PreSolutions.Add(new PreSolution <PositionData, ActionData, CheckPointType>(new GWPosition <PositionData, ActionData>(position.Data.Clone(), position.Depth + 1, position.CategoryPath), null));
        }
Example #3
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);
        }