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 int play() //쥐의 전반적인 행동 { if (!traceback.Any()) { return(-1); } Point top = traceback.Peek(); Point nextPoint = getCurBestPath(getCurBestTarget()); while (nextPoint.X < 0 && nextPoint.Y < 0) //길이 막혀있다면 목적지를 옮긴다. { calculate(-1); nextPoint = getCurBestPath(getCurBestTarget()); } int newX = (int)nextPoint.X; int newY = (int)nextPoint.Y; updateCanvas((int)top.X, (int)top.Y, "road.png"); updateCanvas(newX, newY, "mouse.png"); int dir = mice.moveTo(nextPoint); //다음 지점으로 이동 if (mice.getManaPoint() > 10) //마나가 10 이상이라면 스캔 { int scanX = scan_row + 1; int scanY = scan_col + 1; scan(scanX, scanY); } hpStatus.Value = mice.getHealthPoint(); mpStatus.Value = mice.getManaPoint(); if (mice.getManaPoint() >= 30) //마나가 30 이상이면 { buster(newX, newY); //벽뚫기 } for (int j = newX - 1; j <= newX + 1; j++) { for (int k = newY - 1; k <= newY + 1; k++) { if (j < 0 || k < 0 || j >= Constants.MAX_ARR_LEN || k >= Constants.MAX_ARR_LEN) { continue; } if (j == newX && k == newY) { continue; } revealCanvas(j, k); } } stateLog.Add(new State(maze, mice, "Resources/" + resList[dir])); traceback.Push(new Point(newX, newY)); if (maze.isEndPoint(mice)) { return(1); } object item = myListView.Items[stateLog.Count - 1]; myListView.ScrollIntoView(item); return(0); }