//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();
            }
            // }
        }
Example #2
0
        //________________________________________________________________________

        public virtual Kernel.Matrix Deserialize(System.IO.TextReader reader)
        {
            Kernel.Matrix ret = null;
            if (reader == null)
            {
                return(null);
            }
            //-----
            var matrixsize = new Kernel.Point();

            using (var readflatbuffer = new System.IO.MemoryStream())
            {
                while (matrixsize.Row < byte.MaxValue)
                {
                    string line = reader.ReadLine();

                    //End of file?
                    if (line == null)
                    {
                        break;
                    }


                    byte length;
                    if (line.Length >= byte.MaxValue)
                    {
                        length = byte.MaxValue;
                    }
                    else
                    {
                        length = (byte)line.Length;
                    }

                    //End of matrix?
                    if (length < 3)
                    {
                        if (matrixsize.Column <= byte.MinValue)
                        {
                            continue;
                        }
                        break;
                    }

                    //Remark?
                    string trimline = line.TrimStart();
                    if ((!string.IsNullOrEmpty(trimline)) && (trimline[0] == ';'))
                    {
                        continue;
                    }

                    //First row?
                    if (matrixsize.Column <= byte.MinValue)
                    {
                        matrixsize.Column = (byte)length;
                    }

                    //Read new line ...
                    ++matrixsize.Row;
                    for (byte i = byte.MinValue; i < matrixsize.Column; ++i)
                    {
                        if (i < length)
                        {
                            readflatbuffer.WriteByte(FALSECHARS.IndexOf(line[i]) >= 0 ? (byte)0 : (byte)1);
                        }
                        else
                        {
                            readflatbuffer.WriteByte((byte)0);
                        }
                    } //end for.
                }     //end while.
                //-----
                if ((matrixsize.Column < 3) || (matrixsize.Row < 3))
                {
                    return(null);
                }

                //Convert from flat to matrix ...
                readflatbuffer.Position = 0L;
                ret = new Kernel.Matrix(matrixsize);
                for (byte r = byte.MinValue; r < matrixsize.Row; ++r)
                {
                    for (byte c = byte.MinValue; c < matrixsize.Column; ++c)
                    {
                        ret.m_Buffer[r, c] = readflatbuffer.ReadByte() > 0 ? Kernel.CellType.Fix : Kernel.CellType.None;
                    }
                }
            }//end using.
            return(ret);
        }
        //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();
                }
               // }
        }
Example #4
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();
            }
            // }
        }
        //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();
                }
               // }
        }
        //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();
                }
               // }
        }