コード例 #1
0
        public BeliefState(Problem p)
        {
            Problem = p;
            m_sPredecessor = null;
            m_lObserved = new HashSet<Predicate>();
            Unknown = new HashSet<Predicate>();
            m_lHiddenFormulas = new List<CompoundFormula>();
            m_lOriginalHiddenFormulas = new List<CompoundFormula>();
            m_dMapPredicatesToFormulas = new Dictionary<GroundedPredicate, List<int>>();

            m_lEfficientHidden = new List<EfficientFormula>();
            m_dMapPredicatesToIndexes = new Dictionary<GroundedPredicate, int>();
            m_dMapIndexToPredicate = new List<GroundedPredicate>();
            m_dMapPredicateToEfficientFormula = new List<List<int>>();

            AvailableActions = new List<Action>();
            UnderlyingEnvironmentState = null;
            m_cfCNFHiddenState = new CompoundFormula("and");
            FunctionValues = new Dictionary<string, double>();
            foreach (string sFunction in Problem.Domain.Functions)
            {
                FunctionValues[sFunction] = 0.0;
            }

            bsCOUNT++;
            ID = bsCOUNT;
        }
コード例 #2
0
        public BeliefState(BeliefState sToCopy)
            : this(sToCopy.Problem)
        {
            m_lHiddenFormulas = new List<CompoundFormula>(sToCopy.Hidden);
            m_lOriginalHiddenFormulas = new List<CompoundFormula>(sToCopy.m_lOriginalHiddenFormulas);
            m_dMapPredicatesToFormulas = new Dictionary<GroundedPredicate, List<int>>();
            foreach (KeyValuePair<GroundedPredicate, List<int>> pair in sToCopy.m_dMapPredicatesToFormulas)
            {
                m_dMapPredicatesToFormulas[pair.Key] = new List<int>();
                foreach (int i in pair.Value)
                {
                    m_dMapPredicatesToFormulas[pair.Key].Add(i);
                }
            }
            m_dMapPredicatesToIndexes = new Dictionary<GroundedPredicate, int>(sToCopy.m_dMapPredicatesToIndexes);
            m_dMapPredicateToEfficientFormula = new List<List<int>>();
            foreach (List<int> list in sToCopy.m_dMapPredicateToEfficientFormula)
            {
                List<int> newList = new List<int>();
                foreach (int i in list)
                {
                    newList.Add(i);
                }
                m_dMapPredicateToEfficientFormula.Add(newList);
            }
            m_lObserved = new HashSet<Predicate>(sToCopy.Observed);
            Unknown = new HashSet<Predicate>(sToCopy.Unknown);
            m_cfCNFHiddenState = sToCopy.m_cfCNFHiddenState;

            /*m_sPredecessor = sToCopy.m_sPredecessor;
            AvailableActions = new List<Action>(sToCopy.AvailableActions);
            m_dMapIndexToPredicate = new List<GroundedPredicate>(sToCopy.m_dMapIndexToPredicate);
            UnderlyingEnvironmentState = sToCopy.UnderlyingEnvironmentState;
            if (sToCopy.m_lProblematicTag != null) m_lProblematicTag = new List<Predicate>(sToCopy.m_lProblematicTag);
            m_lCurrentTags = new List<List<Predicate>>();
            foreach (List<Predicate> lp in sToCopy.m_lCurrentTags)
            {
                m_lCurrentTags.Add(new List<Predicate>(lp));
            }*/

            m_dSATVariables = sToCopy.m_dSATVariables;
            m_lSATVariables = sToCopy.m_lSATVariables;

            bsCOUNT++;
            ID = bsCOUNT;
        }
コード例 #3
0
 public void WriteKnowledgeProblem(string sFileName, BeliefState bs)
 {
     StreamWriter sw = new StreamWriter(sFileName);
     sw.WriteLine("(define (problem K" + Problem.Name + ")");
     sw.WriteLine("(:domain K" + Problem.Domain.Name + ")");
     sw.WriteLine("(:init"); //ff doesn't like the and (and");
     /*
     foreach (GroundedPredicate gpKnow in Problem.Known)
     {
         sw.Write("(K" + gpKnow.Name);
         foreach (Constant c in gpKnow.Constants)
             sw.Write(" " + c.Name);
         sw.WriteLine(")");
     }
      * */
     foreach (GroundedPredicate gp in bs.Observed)
     {
         sw.Write("(K" + gp.Name);
         foreach (Constant c in gp.Constants)
             sw.Write(" " + c.Name);
         sw.WriteLine(")");
     }
     foreach (GroundedPredicate gp in Predicates)
     {
         sw.Write("(" + gp.Name);
         foreach (Constant c in gp.Constants)
             sw.Write(" " + c.Name);
         sw.WriteLine(")");
     }
     sw.WriteLine(")");
     HashSet<Predicate> lGoalPredicates = new HashSet<Predicate>();
     Problem.Goal.GetAllPredicates(lGoalPredicates);
     string sGoal = Problem.Goal.ToString();
     sw.WriteLine("(:goal " + sGoal + ")");
     /* Not sure whether we have to KNOW that we have the goal
     sw.Write("(:goal (and " + sGoal);
     foreach (Predicate p in lGoalPredicates)
         Problem.Domain.WriteKnowledgePredicate(sw, p);
     sw.WriteLine("))");
      */
     sw.WriteLine(")");
     sw.Close();
 }
コード例 #4
0
 public abstract void UpdateState(BeliefState bs);
コード例 #5
0
 public virtual PartiallySpecifiedState Clone()
 {
     BeliefState bsCopy = new BeliefState(m_bsInitialBelief);
     PartiallySpecifiedState bsClone = new PartiallySpecifiedState(this, bsCopy);
     return bsClone;
 }
コード例 #6
0
        public PartiallySpecifiedState(PartiallySpecifiedState original, BeliefState bsInitial)
        {
            ID = STATE_COUNT++;

            m_nPlan = original.m_nPlan;
            m_lHistory = new List<string>(original.m_lHistory);
            ChildCount = original.ChildCount;
            if (original.m_lObserved != null)
            {
                m_lObserved = new HashSet<Predicate>();
                foreach (Predicate p in original.m_lObserved)
                {
                    m_lObserved.Add(p);
                }
            }
            else m_lObserved = null;

            if (original.m_lHidden != null)
            {
                m_lHidden = new HashSet<Predicate>();
                foreach (Predicate p in original.m_lHidden)
                {
                    m_lHidden.Add(p);
                }
            }
            else m_lHidden = null;

            if (original.AvailableActions != null)
            {
                AvailableActions = new List<Action>();
                foreach (Action p in original.AvailableActions)
                {
                    AvailableActions.Add(p);
                }
            }
            else AvailableActions = null;

            if (bsInitial == null)
                m_bsInitialBelief = new BeliefState(original.m_bsInitialBelief);
            else
                m_bsInitialBelief = bsInitial;

            if (original.m_sPredecessor != null)
                m_sPredecessor = new PartiallySpecifiedState(original.m_sPredecessor, m_bsInitialBelief);

            /*PartiallySpecifiedState tempPredecessorOriginal = original.m_sPredecessor;
            PartiallySpecifiedState tempPredecessorNew = m_sPredecessor;
            //m_sPredecessor
            while (tempPredecessorOriginal != null)
            {
                tempPredecessorNew = new PartiallySpecifiedState()
            }*/

            if (original.GeneratingAction != null) GeneratingAction = original.GeneratingAction.Clone();
            else GeneratingAction = null;

            if (original.GeneratingObservation != null) GeneratingObservation = original.GeneratingObservation.Clone();
            else GeneratingObservation = null;

            Problem = original.Problem;
            if (original.UnderlyingEnvironmentState != null) UnderlyingEnvironmentState = original.UnderlyingEnvironmentState.Clone();
            else UnderlyingEnvironmentState = null;

            //m_bsInitialBelief = original.m_bsInitialBelief;
            Time = original.Time;

            if (original.m_cfCNFBelief != null) m_cfCNFBelief = new CompoundFormula(original.m_cfCNFBelief);
            else m_cfCNFBelief = null;

            if (original.m_lFailureTag != null) m_lFailureTag = new List<Predicate>(original.m_lFailureTag);
            else m_lFailureTag = null;

            if (original.m_lPreviousTags != null) m_lPreviousTags = new List<List<Predicate>>(original.m_lPreviousTags);
            else m_lPreviousTags = null;

            if (original.FunctionValues != null) FunctionValues = new Dictionary<string, double>(original.FunctionValues);
            else FunctionValues = null;
        }
コード例 #7
0
        public PartiallySpecifiedState(PartiallySpecifiedState sPredecessor, Action aGeneratingAction)
        {
            ID = STATE_COUNT++;

            ChildCount = 0;

            m_bsInitialBelief = new BeliefState(sPredecessor.m_bsInitialBelief);
            Problem = m_bsInitialBelief.Problem;
            AvailableActions = new List<Action>();
            UnderlyingEnvironmentState = null;

            if (Problem.Domain.IsSimple)
            {
                m_sPredecessor = sPredecessor;
            }
            else
            {
                m_sPredecessor = new PartiallySpecifiedState(sPredecessor, m_bsInitialBelief); //recursively copies the entire history
            }

            GeneratingAction = aGeneratingAction;
            m_lObserved = new HashSet<Predicate>(sPredecessor.Observed);
            m_lHidden = new HashSet<Predicate>(sPredecessor.m_lHidden);
            ForgetPotentialEffects();

            FunctionValues = new Dictionary<string, double>();
            Time = sPredecessor.Time + 1;

            foreach (KeyValuePair<string, double> p in sPredecessor.FunctionValues)
                FunctionValues[p.Key] = p.Value;

            m_lHistory = new List<string>(sPredecessor.m_lHistory);
            m_lHistory.Add( GeneratingAction.Name);
        }
コード例 #8
0
        public PartiallySpecifiedState(BeliefState bs)
        {
            ID = STATE_COUNT++;
            Problem = bs.Problem;
            m_sPredecessor = null;
            m_lObserved = new HashSet<Predicate>(bs.Observed);
            AvailableActions = new List<Action>();
            UnderlyingEnvironmentState = bs.UnderlyingEnvironmentState;
            m_bsInitialBelief = bs;
            ChildCount = 0;

            m_lHidden = new HashSet<Predicate>();
            foreach (CompoundFormula cf in bs.Hidden)
            {
                HashSet<Predicate> lCurrent = new HashSet<Predicate>();
                cf.GetAllPredicates(lCurrent);
                foreach (Predicate p in lCurrent)
                {
                    if (p.Negation)
                    {
                        if (!m_lHidden.Contains(p.Negate()))
                            m_lHidden.Add(p.Negate());
                    }
                    else if (!m_lHidden.Contains(p))
                        m_lHidden.Add(p);
                }

            }

            /* as long as there are no non-deterministic effects there is no need to maintain all knowledge
            foreach (Predicate p in bs.Observed)
            {
                if (!Problem.Domain.AlwaysKnown(p))
                    cfBelief.AddOperand(p);
            }
             * */

            FunctionValues = new Dictionary<string, double>();
            foreach (string sFunction in Problem.Domain.Functions)
            {
                FunctionValues[sFunction] = m_bsInitialBelief.FunctionValues[sFunction];
            }

            m_lHistory = new List<string>();
        }
        //public string agentMove(Kernel.Point pLoc, Kernel.Point cLoc)
        //{
        //    switch (cLoc.Column - pLoc.Column)
        //    {
        //        case 1:
        //            return "Agent Moves Right";
        //        case -1:
        //            return "Agent Moves Loft";
        //    }
        //    switch (cLoc.Row - pLoc.Row)
        //    {
        //        case 1:
        //            return "Agent Moves Up";
        //        case -1:
        //            return "Agent Moves Down";
        //    }
        //    return "Agent Didnt Move";
        //}
        public override void UpdateState(BeliefState bs)
        {
            Belief = bs;
            int iSize = GetGridSize();
            //your code here
            Kernel.Matrix bMatrix = new Kernel.Matrix(new Kernel.Point((byte)iSize, (byte)iSize));
            delay();
            int iX = 0, iY = 0;
            GetAgentLocation(out iX, out iY);
            for (int i = 1; i <= iSize; i++)
                for (int j = 1; j <= iSize; j++)
                {
                    if (IsLocationBlocked(i, j))
                    {
                        Console.WriteLine("Blocked " + i + "," + j);
                        // if (board.Created) board.addConsoleText("Blocked " + i + "," + j);
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)),  Kernel.LCellType.Fix);
                    }
                    else if (IsPossibleLocation(i, j))
                    {
                        Console.WriteLine("Agent might be at " + i + "," + j);
                        // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.LCellType.PAgent);
                    }
                    else bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.LCellType.None);
                }
            Console.WriteLine("Agent at " + iX + "," + iY);
               // if (board.Created)
                board.addConsoleText(idx + ") Observation: " + obs + "\r\n    Action: " + act + "\r\n    Agent at: " + iX + "," + iY + "\r\n ----------------------------------------");
            obs = "";
            act = "";
            //if (board.Created) board.addConsoleText(idx + ") " + "Observed:" + GetObservation(bs) + "\r\n Action:" + agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + "\r\n(Agent at " + iX + "," + iY + ")\r\n ----------------------------------------");

            //if (locFlg) { if (board.Created) board.addConsoleText(idx+ ") " + agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + " (Agent at " + iX + "," + iY+ ")\r\n ----------------------------------------"); }
            //else
            //{
            //    locFlg = true;
            //    if (board.Created) board.addConsoleText(idx + ") Agent at " + iX + "," + iY + "\r\n ----------------------------------------");
            //}
            idx++;
            cLoc = new Kernel.Point((byte)iY, (byte)iX);
            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - iY), (byte)(iX - 1)), Kernel.LCellType.Agent);
            //if (board.Created)
               // {
                board.setMatrix(bMatrix);
                if (board.fF == true)
                {
                    board.fF = false;
                    board.stopSpeed();
                }
               // }
        }
コード例 #10
0
        //public string agentMove(Kernel.Point pLoc, Kernel.Point cLoc)
        //{
        //    switch (cLoc.Column - pLoc.Column)
        //    {
        //        case 1:
        //            return "Agent Moves Right";
        //        case -1:
        //            return "Agent Moves Loft";
        //    }
        //    switch (cLoc.Row - pLoc.Row)
        //    {
        //        case 1:
        //            return "Agent Moves Up";
        //        case -1:
        //            return "Agent Moves Down";
        //    }
        //    return "Agent Didnt Move";
        //}
        public override void UpdateState(BeliefState bs)
        {
            Belief = bs;
            int iSize = GetGridSize();
            //your code here
            Kernel.Matrix bMatrix = new Kernel.Matrix(new Kernel.Point((byte)iSize, (byte)iSize));
            delay();
            int iX = 0, iY = 0;
            GetAgentLocation(out iX, out iY);

            for (int i = 1; i <= iSize; i++)
                for (int j = 1; j <= iSize; j++)
                {
                    if (IsUnNone(i, j) && !IsWall(i, j) && !IsDoor(i, j))
                    {
                        //Console.WriteLine("UnNone " + i + "," + j);
                        // if (board.Created) board.addConsoleText("Blocked " + i + "," + j);
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.UnNone);
                    }
                    else if (IsWall(i, j))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.AWall);
                        }
                        else
                        {
                            //Console.WriteLine("Breeze at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.Wall);
                        }
                    }
                    else if (IsDoor(i, j))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.ADoor);
                        }
                        else
                        {
                            //Console.WriteLine("Breeze at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.Door);
                        }
                    }
                    else if (IsGoal(i, j))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.AGoal);
                        }
                        else
                        {
                            //Console.WriteLine("Breeze at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.Goal);
                        }
                    }
                    else if (i == iX && j == iY) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - iY), (byte)(iX - 1)), Kernel.LCellType.Agent);
                    else
                    {
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.DCellType.None);

                    }
                }
            Console.WriteLine("Agent at " + iX + "," + iY);
              //  if (board.Created)
                board.addConsoleText(idx + ") Observation: " + obs + "\r\n    Action: " + act + "\r\n    Agent at: " + iX + "," + iY + "\r\n ----------------------------------------");
            obs = "";
            act = "";
            //if (board.Created) board.addConsoleText(idx + ") " + "Observed:" + GetObservation(bs) + "\r\n Action:" + agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + "\r\n(Agent at " + iX + "," + iY + ")\r\n ----------------------------------------");

            //if (locFlg) { if (board.Created) board.addConsoleText(idx+ ") " + agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + " (Agent at " + iX + "," + iY+ ")\r\n ----------------------------------------"); }
            //else
            //{
            //    locFlg = true;
            //    if (board.Created) board.addConsoleText(idx + ") Agent at " + iX + "," + iY + "\r\n ----------------------------------------");
            //}
            idx++;
            cLoc = new Kernel.Point((byte)iY, (byte)iX);

            //if (board.Created)
               // {
                board.setMatrix(bMatrix);
                if (board.fF == true)
                {
                    board.fF = false;
                    board.stopSpeed();
                }
               // }
        }
コード例 #11
0
        //public string agentMove(Kernel.Point pLoc, Kernel.Point cLoc)
        //{
        //    switch (cLoc.Column - pLoc.Column)
        //    {
        //        case 1:
        //            return "Agent Moves Right";
        //        case -1:
        //            return "Agent Moves Loft";
        //    }
        //    switch (cLoc.Row - pLoc.Row)
        //    {
        //        case 1:
        //            return "Agent Moves Up";
        //        case -1:
        //            return "Agent Moves Down";
        //    }
        //    return "Agent Didnt Move";
        //}
        public override void UpdateState(BeliefState bs)
        {
            Belief = bs;
            int iSize = GetGridSize();
            //your code here
            Kernel.Matrix bMatrix = new Kernel.Matrix(new Kernel.Point((byte)iSize,(byte)iSize));
            delay();
            int iX = 0, iY = 0;
            GetAgentLocation(out iX, out iY);
            cLoc = new Kernel.Point((byte)iY, (byte)iX);
            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - iY), (byte)(iX - 1)), Kernel.MCellType.Agent);
            for (int i = 1; i <= iSize; i++)
                for (int j = 1; j <= iSize; j++)
                {
                    //if (IsUnNone(i, j))
                    //{
                    //    Console.WriteLine("UnNone " + i + "," + j);
                    //    // if (board.Created) board.addConsoleText("Blocked " + i + "," + j);
                    //    bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.UnNone);
                    //    bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j+1), (byte)(i - 1)), Kernel.MCellType.Pfeeling);
                    //    //bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i)), Kernel.MCellType.Pfeeling);
                    //    bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j - 1), (byte)(i - 1)), Kernel.MCellType.Pfeeling);
                    //    bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 2)), Kernel.MCellType.Pfeeling);
                    //}
                    if (IsPossibaleFeeling(i, j)&&!((i==iX)&&(j==iY)))
                    {
                        //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                        // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Pfeeling);
                    }

                    if (IsUnSafe(i,j))
                    {
                        //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                        // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                        if (j > i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.UnNoneUp);
                        if (j < i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.UnNoneDown);
                    }
                    else if (IsSafe(i, j))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                            if (j > i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.ANoneUp);
                            if (j < i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.ANoneDown);
                        }
                        else
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                            if (j > i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.NoneUp);
                            if (j < i) bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.NoneDown);
                        }
                    }
                   else if ((IsFeelingBreeze(i, j))&&(IsFeelingStench(i, j)))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze & Stench at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.AbreezeStench);
                        }
                        else
                        {
                            Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Feeling Breeze & Stench at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Feeling);
                        }
                    }
                    else if (IsFeelingStench(i, j))
                        {
                            if (i == iX && j == iY)
                            {
                                //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                                //if (board.Created) board.addConsoleText("Feeling Stench at " + i + "," + j);
                                bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Astench);
                            }
                            else
                            {
                                Console.WriteLine("Stench at " + i + "," + j);
                                //if (board.Created) board.addConsoleText("Feeling Stench at " + i + "," + j);
                                bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Stench);
                            }
                        }
                   else if (IsFeelingBreeze(i, j))
                   {
                       if (i == iX && j == iY)
                       {
                           //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                           //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                           bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Abreeze);
                       }
                       else
                       {
                           Console.WriteLine("Breeze at " + i + "," + j);
                           //if (board.Created) board.addConsoleText("Feeling Breeze at " + i + "," + j);
                           bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Breeze);
                        }
                    }
                    if (IsWumpus(i, j) && (IsPit(i, j)))
                    {
                        Console.WriteLine("wumpus & pit at " + i + "," + j);
                        //if (board.Created) board.addConsoleText("Wumpus & Pit at " + i + "," + j);
                        bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.WumpusPit);
                    }
                   else if (IsWumpus(i,j))
                   {
                       Console.WriteLine("wumpus at " + i + "," + j);
                       //if (board.Created) board.addConsoleText("wumpus at " + i + "," + j);
                       bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Wumpus);
                   }
                   else if (IsPit(i, j))
                   {
                       Console.WriteLine("pit at " + i + "," + j);
                       //if (board.Created) board.addConsoleText("Pit at " + i + "," + j);
                       bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Pit);
                   }
                    if (IsCrown(i, j))
                    {
                        if (i == iX && j == iY)
                        {
                            //Console.WriteLine("Breeze and Stench at " + i + "," + j);
                            // if (board.Created) board.addConsoleText("Agent might be at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Acrown);
                        }
                        else
                        {
                            Console.WriteLine("gold at " + i + "," + j);
                            //if (board.Created) board.addConsoleText("Gold at at " + i + "," + j);
                            bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.MCellType.Crown);
                        }
                    }
                    //else bMatrix.addCellValue(new Kernel.Point((byte)(iSize - j), (byte)(i - 1)), Kernel.LCellType.None);
                }
            Console.WriteLine("Agent at " + iX + "," + iY);
            //if (board.Created)
                board.addConsoleText(idx + ") Observation: " + obs + "\r\n    Action: " +act+"\r\n    Agent at: " + iX + "," + iY + "\r\n ----------------------------------------");
            obs = "";
            act = "";
            //if (board.Created) board.addConsoleText(idx + ") " +(GetObservation()!=""?"Observed:\r\n"+GetObservation():"No Observation\r\n") +"Action:\r\n"+ agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + " (Agent at " + iX + "," + iY + ")\r\n ----------------------------------------");

            //if (locFlg) { if (board.Created) board.addConsoleText(idx+ ") " + agentMove(cLoc, new Kernel.Point((byte)iY, (byte)iX)) + " (Agent at " + iX + "," + iY+ ")\r\n ----------------------------------------"); }
            //else
            //{
            //    locFlg = true;
            //    if (board.Created) board.addConsoleText(idx + ") Agent at " + iX + "," + iY + "\r\n ----------------------------------------");
            //}
            idx++;

            //if (board.Created)
            //{
                board.setMatrix(bMatrix);
                if (board.fF == true)
                {
                    board.fF = false;
                    board.stopSpeed();
                }
               // }
        }
コード例 #12
0
 internal void WriteTaggedProblem(string p, BeliefState bsCurrent)
 {
     throw new NotImplementedException();
 }