Beispiel #1
0
 public static Path4 <T> GetPlanning(List <ActionBase4 <T> > actions, T agent, ActionBase4 <T> goal, int minValue)
 {
     if (goal.CheckCondition(agent))
     {
         Path4 <T> path = pathPool.New();
         path.Reset();
         path.Append(goal);
         return(path);
     }
     else
     {
         int             maxValue    = -99999;
         ActionBase4 <T> bestAction  = null;
         Path4 <T>       bestSubPath = null;
         foreach (ActionBase4 <T> action in actions)
         {
             if (action.CheckCondition(agent))
             {
                 if (action.GetValue() >= minValue)
                 {
                     T         newAgent = action.PerformEffect(agent);
                     Path4 <T> subPath  = GetPlanning(actions, newAgent, goal, minValue - action.GetValue());
                     if (subPath != null)
                     {
                         int value = action.GetValue() + subPath.Value;
                         if (value > maxValue)
                         {
                             if (bestSubPath != null)
                             {
                                 pathPool.Recycle(bestSubPath);
                             }
                             maxValue    = value;
                             bestAction  = action;
                             bestSubPath = subPath;
                         }
                         else
                         {
                             pathPool.Recycle(subPath);
                         }
                     }
                 }
             }
         }
         if (bestAction != null)
         {
             bestSubPath.AddHead(bestAction);
             return(bestSubPath);
         }
     }
     return(null);
 }
Beispiel #2
0
 public void AddHead(ActionBase4 <T> action)
 {
     actions.Insert(0, action);
     value += action.GetValue();
 }
Beispiel #3
0
 public void Append(ActionBase4 <T> action)
 {
     actions.Add(action);
     value += action.GetValue();
 }