Пример #1
0
        private static bool fillMaze(State state, short stateSide, int position)
        {
            int side = (stateSide + 1) % 2;                                                                 //Change side

            state.setStep((short)(state.getStep() + 1));                                                    //step++
            for (int i = 1; i < state.getMaze()[state.getHuman().getX()][state.getHuman().getY()].Length; i++)
            {                                                                                               //adding marker
                if (state.getMaze()[state.getHuman().getX()][state.getHuman().getY()][i] < 1)
                {                                                                                           //check if can add marker
                    state.getMaze()[state.getHuman().getX()][state.getHuman().getY()][i] = state.getStep(); //add marker to maze
                    break;
                }
            }
            StaticState staticState = new StaticState(state);

            if (!staticState.existing())
            {
                MainProcess.stateSideCount[side]++;                               //Increase count
                MainProcess.mang[side][MainProcess.stateSideCount[side]] = state; //add new State to the other side
                MainProcess.getExistedState().Add(staticState);                   //add new state to existing States
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 public bool existing()
 {
     for (int i = 0; i < MainProcess.getExistedState().Count; i++)
     {
         if (this.equals(MainProcess.getExistedState()[i]))
         {
             return(true);
         }
     }
     return(false);
 }