コード例 #1
0
ファイル: GoalStack.cs プロジェクト: ktp-forked-repos/Mara
/*
 *              private void AddTest( Goal goal )
 *              {
 *                      GoalOr goalOr	= goal as GoalOr;
 *
 *                      if( !ReferenceEquals( goalOr, null ) )
 *                      {
 *                              AddObjective();
 *
 *                              m_StackAnd.Push( goal );
 *                              m_StackAndMax	= Math.Max( m_StackAndMax, m_StackAnd.Count );
 *
 *                              m_StackOr.Push( goalOr );
 *                              m_StackOrCount++;
 *                              m_StackOrMax	= Math.Max( m_StackOrMax, m_StackOr.Count );
 *                      }
 *                      else
 *                      {
 *                              m_StackAnd.Push( goal );
 *                              m_StackAndMax	= Math.Max( m_StackAndMax, m_StackAnd.Count );
 *                      }
 *              }
 */

        public void Fail()
        {
            ++m_CountFail;

            m_IsFailed = m_StackOr.Count == 0;
            if (m_IsFailed)
            {
                m_StackAnd.Clear();
            }
            else
            {
                GoalOr goal = m_StackOr.Peek();

                goal.Pop();

                if (goal.IsDone())
                {
                    m_StackOr.Pop();

                    Fail();
                }
                else
                {
                    if (!ReferenceEquals(m_IntObjective.Var, null))
                    {
                        m_StackAnd.Push(m_IntObjective.Create());
                    }

                    m_StackAnd.Push(goal);
                }
            }
        }
コード例 #2
0
ファイル: GoalStack.cs プロジェクト: ktp-forked-repos/Mara
        public void Add(Goal goal)
        {
            m_StackAnd.Push(goal);
            m_StackAndMax = Math.Max(m_StackAndMax, m_StackAnd.Count);

            GoalOr goalOr = goal as GoalOr;

            if (!ReferenceEquals(goalOr, null))
            {
                m_StackOr.Push(goalOr);
                m_StackOrCount++;
                m_StackOrMax = Math.Max(m_StackOrMax, m_StackOr.Count);
            }
        }
コード例 #3
0
ファイル: Cover.cs プロジェクト: nofear/Mara
            public override void Execute()
            {
                if( m_Cover.IsBound() )
                    return;

                int index    = m_Cover.Select();
                if( index > m_Cover.m_Avail.Max )
                {
                    Fail();
                    return;
                }

                //ExecuteDelegate add = delegate { m_Cover.Add( index ); };

                Goal choice1	= new GoalAnd( new AddIndex( m_Cover, index ), m_Cover.m_Avail != index );
                Goal choice2	= m_Cover.m_Avail != index;
                Goal search		= new GoalOr( choice1, choice2 );

                Add( new GoalAnd( search, this ) );
            }