Ejemplo n.º 1
0
        public State cloneState()
        {
            short [][][]    mazee       = this.getMaze();
            Keyd []         newKey      = this.getKey();
            MummyWhite[]    mummyWhitee = this.getMummyWhite();
            MummyRed[]      mummyRede   = this.getMummyRed();
            ScorpionWhite[] ske         = this.getSk();
            ScorpionRed []  skRede      = this.getSkRed();
            Human           humane      = this.getHuman();
            short           stepe       = this.getStep();

            short[][][] newMaze = new short[mazee.Length][][];
            for (int i = 0; i < newMaze.Length; i++)
            {
                newMaze[i] = new short[mazee[0].Length][];
                for (int j = 0; j < newMaze[i].Length; j++)
                {
                    newMaze[i][j] = new short[mazee[0][0].Length];
                }
            }

            for (int i = 0; i < mazee.Length; i++)
            {
                for (int j = 0; j < mazee[0].Length; j++)
                {
                    for (int k = 0; k < mazee[0][0].Length; k++)
                    {
                        newMaze[i][j][k] = mazee[i][j][k];
                    }
                }
            }

            MummyWhite[] newMummyWhite = new MummyWhite[mummyWhitee.Length];
            for (int i = 0; i < mummyWhitee.Length; i++)
            {
                newMummyWhite[i] = new MummyWhite(mummyWhitee[i].getX(), mummyWhitee[i].getY());
            }
            MummyRed[] newMummyRed = new MummyRed[mummyRede.Length];
            for (int i = 0; i < mummyRede.Length; i++)
            {
                newMummyRed[i] = new MummyRed(mummyRede[i].getX(), mummyRede[i].getY());
            }
            ScorpionWhite[] newSk = new ScorpionWhite[ske.Length];
            for (int i = 0; i < ske.Length; i++)
            {
                newSk[i] = new ScorpionWhite(ske[i].getX(), ske[i].getY());
            }
            ScorpionRed [] newSkRed = new ScorpionRed[skRede.Length];
            for (int i = 0; i < skRede.Length; i++)
            {
                newSkRed[i] = new ScorpionRed(skRed[i].getX(), skRed[i].getY());
            }
            Human newHuman = new Human(humane.getX(), humane.getY());
            short newStep  = stepe;

            State newState = new State(newMaze, newKey, newMummyWhite, newMummyRed, newSk, newSkRed, newHuman, newStep);

            return(newState);
        }
Ejemplo n.º 2
0
        private static Mummy[] deleteMummy(Mummy[] mummy, int i)
        {
            for (int j = i; j < mummy.Length - 1; j++)
            {
                mummy[j] = mummy[j + 1];
            }
            Type invoker = mummy[i].GetType();

            Mummy[] tam = null;
            //        for (int j = 0; j < tam.length; j++) {
            //            tam[j] = mummy[j];
            //        }
            if (invoker.Equals(typeof(MummyWhite)))
            {
                tam = new MummyWhite[mummy.Length - 1];
                for (int j = 0; j < mummy.Length - 1; j++)
                {
                    tam[j] = new MummyWhite(mummy[j].getX(), mummy[j].getY());
                }
            }
            else if (invoker.Equals(typeof(MummyRed)))
            {
                tam = new MummyRed[mummy.Length - 1];
                for (int j = 0; j < mummy.Length - 1; j++)
                {
                    tam[j] = new MummyRed(mummy[j].getX(), mummy[j].getY());
                }
            }
            else if (invoker.Equals(typeof(ScorpionWhite)))
            {
                tam = new ScorpionWhite[mummy.Length - 1];
                for (int j = 0; j < mummy.Length - 1; j++)
                {
                    tam[j] = new ScorpionWhite(mummy[j].getX(), mummy[j].getY());
                }
            }
            else if (invoker.Equals(typeof(ScorpionRed)))
            {
                tam = new ScorpionRed[mummy.Length - 1];
                for (int j = 0; j < mummy.Length - 1; j++)
                {
                    tam[j] = new ScorpionRed(mummy[j].getX(), mummy[j].getY());
                }
            }
            return(tam);
        }
Ejemplo n.º 3
0
        public MummyWhite mummyWhiteMove(short[][][] maze, Human man)
        {//Horizontal then vertical
            //This method was written using a different logic than the current one
            MummyWhite tam = new MummyWhite(this.getX(), this.getY());

            if (tam.samePlace(man))
            {
                return(tam);
            }
            else
            {
                Mummy.setAttempt(0);
                Mummy.setCount(0);
                while ((Mummy.getAttempt() < 5) && (Mummy.getCount() < 1))
                {
                    while (tam.getY() != man.getY())
                    {
                        tam = (MummyWhite)tam.mummyMoveHorizontal(maze, man);
                        if (!(Mummy.getCount() < 1))
                        {
                            return(tam);
                        }
                        if (Mummy.getAttempt() > 4)
                        {
                            break;
                        }
                    }
                    if (tam.samePlace(man))
                    {
                        return(tam);
                    }
                    tam = (MummyWhite)tam.mummyMoveVertical(maze, man);
                    if ((tam.samePlace(man)) || (!(Mummy.getCount() < 1)))
                    {
                        return(tam);
                    }
                }
                return(tam);
            }
        }