예제 #1
0
 /// <summary>
 /// foamliu, 2009/01/22.
 ///
 /// 测试跟另外一个合取式是否有交集.
 /// </summary>
 /// <param name="otherConj"></param>
 /// <returns></returns>
 public bool Intersect(Conjunction otherConj)
 {
     foreach (string literal in m_literals)
     {
         if (otherConj.Contains(literal))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        /// <summary>
        /// foamliu, 2009/01/20.
        /// 找到所有这样的 actions: 它们的 Preconditions 在 thePre 里.
        ///
        /// </summary>
        /// <param name="thePre"></param>
        /// <returns></returns>
        public List <Action> GenActions(Conjunction thePre)
        {
            List <Action> actions = new List <Action>();
            List <string> vars    = m_opHead.ParaList.Vars;

            foreach (string s in m_validUnifiers)
            {
                Unifier     un   = new Unifier(vars, s);
                string      aPre = Util.Substitute(m_pre, un);
                Conjunction conj = new Conjunction(aPre);

                if (thePre.Contains(conj))
                {
                    // 创建一个 action
                    string aHead = Util.Substitute(m_opHead, un);
                    string aAdd  = Util.Substitute(m_add, un);
                    string aDel  = Util.Substitute(m_del, un);

                    actions.Add(new Action(aHead, aPre, aAdd, aDel));
                }
            }

            return(actions);
        }