public PlanSet GetPlan(Goal goal, List<PloobsEngine.IA.Action> Actions)
        {
                AstarPlanner Planner = new AstarPlanner();
                Planner.MaxIteration = int.MaxValue;
                Planner.Actions = Actions;
                WorldState WorldState = BlackBoard.GetEntry<WorldState>("WorldState");
                                                           
                PlanSet PlanSet = Planner.CreatePlan(
                    WorldState,
                    goal
                    );

                return PlanSet;
        }
 public override PlanSet CreatePlan(WorldState actual, Goal destiny)
 {
     this.destiny = destiny;
     act.Clear();
     iter = 0;
     PlanSet PlanSet =null;                        
     
     if (depthSearch(actual) == true)
     {
         PlanSet = new PlanSet();
         foreach (var item in act)
         {
             PlanSet.Actions.Add(item);
             System.Diagnostics.Debug.WriteLine(item.Name);
         }
         
     }
     return PlanSet;
 }
        public override PlanSet CreatePlan(WorldState actual, Goal destiny)
        {
            PlanSet PlanSet = new PlanSet();
                        
            WorldState current = actual.Clone();
            int iter = 0;
            while (!destiny.Evaluate(current))
            {
                Action act = null;
                foreach (var item in Actions)
                {
                    if (item.GetPreConditions(current).isCompatibleSource(current))
                    {
                        if (item.ProceduralPreConditions(current))
                        {
                            act = item;
                            break;
                        }
                    }
                }

                if (act != null)
                {
                    foreach (var item in act.GetEffects(current).GetSymbols())
                    {
                        current.SetSymbol(item.Clone());
                    }
                    act.ApplyEffects(current);
                }
                else
                {
                    return null;
                }
                iter++;
                if (iter > MaxIteration)
                    return null;
                
                System.Diagnostics.Debug.WriteLine(act.Name);
            }
            System.Diagnostics.Debug.WriteLine(destiny.Name);
           return PlanSet;
        }
Exemplo n.º 4
0
 public abstract PlanSet CreatePlan(WorldState actual, Goal destiny);
Exemplo n.º 5
0
        public override PlanSet CreatePlan(WorldState actual, Goal destiny)
        {
            int     iter    = 0;
            PlanSet PlanSet = new PlanSet();
            PriorityQueueB <pathrecnode> processing = new PriorityQueueB <pathrecnode>(new comparer());
            List <WorldState>            close      = new List <WorldState>();

            processing.Push(
                new pathrecnode()
            {
                act        = new List <Action>(),
                WorldState = actual,
                f          = 0,
                g          = 0,
                h          = 0,
            }
                );

            pathrecnode current = null;

            while (processing.Count != 0)
            {
                current = processing.Pop();

                if (destiny.Evaluate(current.WorldState) == true)
                {
                    break;
                }

                if (close.Contains(current.WorldState))
                {
                    continue;
                }
                else
                {
                    close.Add(current.WorldState);
                }

                List <Action> acts = new List <Action>();
                foreach (var item in Actions)
                {
                    if (item.GetPreConditions(current.WorldState).isCompatibleSource(current.WorldState))
                    {
                        if (item.ProceduralPreConditions(current.WorldState))
                        {
                            acts.Add(item);
                        }
                    }
                }

                foreach (var item in acts)
                {
                    WorldState ws = current.WorldState.Clone();
                    foreach (var item2 in item.GetEffects(current.WorldState).GetSymbols())
                    {
                        ws.SetSymbol(item2.Clone());
                    }
                    item.ApplyEffects(ws);

                    pathrecnode pathrec = new pathrecnode();
                    pathrec.WorldState = ws;
                    pathrec.act        = new List <Action>(current.act.ToArray());
                    pathrec.act.Add(item);
                    pathrec.g += 1 + item.Cost;
                    pathrec.h  = destiny.GetHeuristic(pathrec.WorldState);
                    //pathrec.WorldState.GetHeuristic(destiny.WorldState);
                    pathrec.f = pathrec.g + pathrec.h;
                    processing.Push(pathrec);
                }


                iter++;
                if (iter > MaxIteration)
                {
                    return(null);
                }

                Debug(processing, iter);
            }

            if (current != null)
            {
                foreach (var item in current.act)
                {
                    PlanSet.Actions.Add(item);
                    System.Diagnostics.Debug.WriteLine(item.Name);
                }
            }


            return(PlanSet);
        }
Exemplo n.º 6
0
 public abstract PlanSet CreatePlan(WorldState actual, Goal destiny);
        public override PlanSet CreatePlan(WorldState actual, Goal destiny)
        {

            PlanSet PlanSet = new PlanSet();
            LinkedList<pathrec> processing = new LinkedList<pathrec>();

            processing.AddLast(
                new pathrec()
                {
                    act = new List<Action>(),
                    WorldState = actual
                }
                );

            int iter = 0;
            pathrec current = null;
            while (processing.Count != 0)
            {
                current = processing.First.Value;
                processing.RemoveFirst();

                if (destiny.Evaluate(current.WorldState) == true)
                    break;

                List<Action> acts = new List<Action>();
                foreach (var item in Actions)
                {
                    if (item.GetPreConditions(current.WorldState).isCompatibleSource(current.WorldState))
                    {
                        if (item.ProceduralPreConditions(current.WorldState))
                        {
                            acts.Add(item);
                        }
                    }
                }
                
                foreach (var item in acts)
                {
                    WorldState ws = current.WorldState.Clone();
                    foreach (var item2 in item.GetEffects(current.WorldState).GetSymbols())
                    {
                        ws.SetSymbol(item2.Clone());
                    }
                    item.ApplyEffects(ws);

                    System.Diagnostics.Debug.WriteLine(item.Name);

                    pathrec pathrec = new pathrec();
                    pathrec.WorldState = ws;
                    pathrec.act = new List<Action>(current.act.ToArray());
                    pathrec.act.Add(item);
                    processing.AddLast(pathrec);                    
                }

                System.Diagnostics.Debug.WriteLine("---START");                
                foreach (var item in processing)
                {
                    System.Diagnostics.Debug.WriteLine("-<>-");
                    foreach (var item2 in item.act)
                    {
                        System.Diagnostics.Debug.WriteLine(item2.Name);    
                    }
                    
                }
                System.Diagnostics.Debug.WriteLine("---END");

                iter++;
                if (iter > MaxIteration)
                    return null;

            }

            if (current != null)
            {
                foreach (var item in current.act)
                {
                    PlanSet.Actions.Add(item);
                    System.Diagnostics.Debug.WriteLine(item.Name);
                }
            }

            
            return PlanSet;
        }