示例#1
0
   /// This method applies an Action to a WorldState in reverse. In effect,
   /// it determines the state of the world required that when this Action is
   /// applied to it, the result is the current state.
   /// This involves making sure that the new state's predicates match the
   /// Action's prerequisites, and clearing any predicates that the Action
   /// sets.
   void WorldState::applyReverse(const Action &ac, const objects &params)
   {
      operations::const_iterator o;
      Operation op;
      Fact f;
      for(o = ac.begin(); o != ac.end(); o++)
      {
         op = o->second;
         f = o->first;
         if(params.size())
         {
            fillOp(op, params);
            fillFact(f, params);
         }
         // If there's no condition, check the effects.
         if(op.ctype == NoCondition)
         {
            switch(op.etype)
            {
            case Set:
                //_set(f,op.eval);
               _unset(f);
               break;
            case Unset:
               _set(f,op.eval);
               break;
            case Increment:
               _set(f, op.eval - 1);
               break;
            case Decrement:
               _set(f, op.eval + 1);
               break;
            }
         }
         else
         {
            switch(op.ctype)
            {
            case IsSet:
               _set(f, 0);
               break;
            case Equals:
               _set(f, op.cval);
               break;
            case IsUnset:
               _unset(f);
               break;
            }
         }
      }

      updateHash();
   }
 void SimpleWorldState::unset(Predicates::predID pred, const paramlist &params)
 {
    if(pred < mState.size())
    {
       _unset(pred, params);
       updateHash();
    }
 }
示例#3
0
 void WorldState::unset(const Fact &fact)
 {
    _unset(fact);
    updateHash();
 }