public void rotation(Maze m, Mice mice, int temp = 0) { if (count != -1) //스캔으로 도착지를 찾지 않았다면 { //도착지 로테이션 구현 //쥐가 기억하고 있는 위치이고, 벽이라면 목적지 변경 while ((mice.getMemory().getMemory(end_row, end_col) == Constants.MEMORY && !m.isAvailable(end_row, end_col)) || temp == -1) { if (end_col == 1 && end_row < m.getRow()) { end_row++; } else if (end_col < m.getCol() && end_row == m.getRow()) { end_col++; } else if (end_col == m.getCol() && end_row > 1) { end_row--; } else if (end_col > 1 && end_row == 1) { end_col--; } temp = 0; } } }
public Mice(Mice mice) { memory = new Memory(mice.getMemory()); curPoint = new Point(mice.getCurPoint().X, mice.getCurPoint().Y); this.healthPoint = mice.getHealthPoint(); this.manaPoint = mice.getManaPoint(); }
public State(Maze maze, Mice mice, String dir) { this.curMaze = new Maze(maze); this.curMice = new Mice(mice); Point p = curMice.getCurPoint(); cord = "( " + p.X + " , " + p.Y + " ) "; step = "" + curMice.getMemory().getStep(); this.dir = dir; }
public void calculateInnerPath(Point p, Maze m, Mice mice) { int[,] dirPriority = new int[4, 2] { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } }; bool[,] visit = new bool[m.getRow() + 2, m.getCol() + 2]; Queue <Node> buf = new Queue <Node>(); Node resultNode = null; Point endPoint = mice.getCurPoint(); buf.Enqueue(new Node(p, null)); visit[(int)p.X, (int)p.Y] = true; do { Node curNode = buf.Dequeue(); Point curPoint = curNode.getChild(); if (curPoint.X == endPoint.X && curPoint.Y == endPoint.Y) { resultNode = curNode; } for (int i = 0; i < 4; i++) { int newX = (int)curPoint.X + dirPriority[i, 0]; int newY = (int)curPoint.Y + dirPriority[i, 1]; if (newX <= 0 || newY <= 0 || newX > m.getRow() || newY > m.getCol()) { continue; } if (visit[newX, newY]) { continue; } if (mice.getMemory(newX, newY) == 0) { continue; } if (mice.getMemory(newX, newY) < 0 && !m.isAvailable(newX, newY)) { continue; } Point newPoint = new Point(newX, newY); buf.Enqueue(new Node(newPoint, curNode)); visit[newX, newY] = true; } } while (buf.Any()); if (resultNode != null) { Node curNode = resultNode; int step = 1; Point startPoint = curNode.getChild(); Point nextPoint = new Point(-1, -1); while (curNode != null) { innerChache[(int)startPoint.X, (int)startPoint.Y].Add(new TileNode(p, nextPoint, step++)); curNode = curNode.getParent(); if (curNode == null) { break; } nextPoint = startPoint; startPoint = curNode.getChild(); } } }
public void clearPath() { Point calcPoint = new Point(1, 2); for (int i = 1; i <= maze.getRow(); i++) { for (int j = 1; j <= maze.getCol(); j++) { if (maze.isAvailable(i, j) && (mice.getMemory(i, j) == Constants.MEMORY)) { calcPoint = new Point(i, j); shortPath.clearInnerWay(calcPoint); shortPath.clearWay(calcPoint); } } } }