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); } }
public MainProcess(State state, short xxExit, short yyExit, List <int> solution) { StaticState tam = new StaticState(state); state.setStep((short)1); state.getMaze()[state.getHuman().getX()][state.getHuman().getY()][1] = 1; stateSide = 0; stateSideCount[stateSide] = 0; //It's count - 1 for the array sake stateSideCount[(short)((stateSide + 1) % 2)] = -1; mang[0][0] = state; xExit = xxExit; yExit = yyExit; mang[0][0] = state; existedState = new List <StaticState>(); existedState.Add(tam); breadthFirstSearch(solution); //printResult(tam); }
private bool equals(StaticState statics) { for (int i = 0; i < this.getStaticMaze().Length; i++) { for (int j = 0; j < this.getStaticMaze()[0].Length; j++) { if (!(this.getStaticMaze()[i][j] == (statics.getStaticMaze()[i][j]))) { return(false); } } } if (this.getMummyWhite().Length != statics.getMummyWhite().Length) { return(false); } else { for (int i = 0; i < this.getMummyWhite().Length; i++) { if (!(this.getMummyWhite()[i].samePlace(statics.getMummyWhite()[i]))) { return(false); } } } if (this.getMummyRed().Length != statics.getMummyRed().Length) { return(false); } else { for (int i = 0; i < this.getMummyRed().Length; i++) { if (!(this.getMummyRed()[i].samePlace(statics.getMummyRed()[i]))) { return(false); } } } if (this.getSk().Length != statics.getSk().Length) { return(false); } else { for (int i = 0; i < this.getSk().Length; i++) { if (!(this.getSk()[i].samePlace(statics.getSk()[i]))) { return(false); } } } if (this.getSkRed().Length != statics.getSkRed().Length) { return(false); } else { for (int i = 0; i < this.getSkRed().Length; i++) { if (!(this.getSkRed()[i].samePlace(statics.getSkRed()[i]))) { return(false); } } } if (!(this.getHuman().samePlace(statics.getHuman()))) { return(false); } return(true); }