Exemple #1
0
        public static List <IPlanStep> ReadPlayerTrace(string directory, Domain domain, Problem problem)
        {
            var planTrace = new List <IPlanStep>();

            string[] input = System.IO.File.ReadAllLines(directory);

            foreach (var line in input)
            {
                var opToken  = PlayerTraceUtilities.CreateOperatorToken(line);
                var iopToken = PlayerTraceUtilities.AddPreconditionsAndEffects(opToken, domain);

                // make sure we don't accidentally use.... <_<, >_>
                opToken = null;

                var newStep = new PlanStep();

                if (GroundActionFactory.GroundActions.Contains(iopToken))
                {
                    var opIndex         = GroundActionFactory.GroundActions.IndexOf(iopToken);
                    var existingOpToken = GroundActionFactory.GroundActions[opIndex];
                    newStep = new PlanStep(existingOpToken.Clone() as IOperator);
                }
                else
                {
                    GroundActionFactory.InsertOperator(iopToken);
                    newStep = new PlanStep(iopToken.Clone() as IOperator);
                }

                planTrace.Add(newStep);
            }

            return(planTrace);
        }
Exemple #2
0
        public static void AddCompositeStepsToGroundActionFactory(List <IPredicate> Initial, List <IPredicate> Goal, List <CompositeSchedule> compositeSteps)
        {
            var originalOps = GroundActionFactory.GroundActions;
            //CacheMaps.CacheLinks(originalOps);
            var IOpList = new List <IOperator>();

            foreach (var compstep in compositeSteps)
            {
                var asIOp = compstep as IOperator;
                IOpList.Add(asIOp);
                GroundActionFactory.InsertOperator(asIOp);
            }

            // Update Heuristic value for primary effects.
            PrimaryEffectHack(new State(Initial) as IState);

            // Amonst themselves
            CacheMaps.CacheLinks(IOpList);

            // as consequents to the originals
            CacheMaps.CacheLinks(originalOps, IOpList);

            // as antecedants to the originals
            CacheMaps.CacheLinks(IOpList, originalOps);

            // as antecedants to goal conditions
            CacheMaps.CacheGoalLinks(originalOps, Goal);
            CacheMaps.CacheGoalLinks(IOpList, Goal);
        }
Exemple #3
0
        public void AddCompositeStepsToGroundActionFactory(List <CompositeSchedule> compositeSteps)
        {
            var goalConditions = InitialPlan.GoalStep.Preconditions;
            var originalOps    = GroundActionFactory.GroundActions;

            var IOpList = new List <IOperator>();

            foreach (var compstep in compositeSteps)
            {
                var asIOp = compstep as IOperator;
                IOpList.Add(asIOp);
                GroundActionFactory.InsertOperator(asIOp);
            }

            // Update Heuristic value for primary effects.
            PrimaryEffectHack(InitialPlan.Initial);

            // Amonst themselves
            CacheMaps.CacheLinks(IOpList);

            // as antecedants to the originals
            CacheMaps.CacheLinks(IOpList, originalOps);

            // as consequents to the originals
            CacheMaps.CacheLinks(originalOps, IOpList);

            // as antecedants to goal conditions
            CacheMaps.CacheGoalLinks(IOpList, goalConditions);

            // is is possible to have a new precondition here that is static?
            /// this raises a larger point.
            /// should we say that initially we observe the way the world is? (yes)
            /// should we create simple camera shots for conveying actions so that effects of actions are all observable?
            /// this is an experimental condition of sorts. In this case, there is no non-static condition that is not observable.
            /// therefore, (no), there is no need for (extra) statics.

            // There is also no need to cache addreuseheuristic again because primitive values.
            //CacheMaps.CacheAddReuseHeuristic(InitialPlan.Initial);
        }