1.1 --- a/icfp-model/src/main/java/ru/bosony/model/game/Game.java Sun Jul 15 21:36:42 2012 +0400
1.2 +++ b/icfp-model/src/main/java/ru/bosony/model/game/Game.java Mon Jul 16 00:05:50 2012 +0400
1.3 @@ -7,6 +7,8 @@
1.4 import static ru.bosony.model.cellscontents.CellContent.MiningRobot;
1.5 import static ru.bosony.model.cellscontents.CellContent.OpenLambdaLift;
1.6 import static ru.bosony.model.cellscontents.CellContent.Rock;
1.7 +import static ru.bosony.model.cellscontents.CellContent.HuttonsRazor;
1.8 +import static ru.bosony.model.cellscontents.CellContent.WadlersBeard;
1.9
1.10 import java.util.ArrayList;
1.11 import java.util.List;
1.12 @@ -66,7 +68,8 @@
1.13
1.14 // Moving and scoring
1.15 route.add(mov);
1.16 - Coordinate robotCoord = mine.getRobotCell().getCoordinate();
1.17 + Cell robotCell = mine.getRobotCell();
1.18 + Coordinate robotCoord = robotCell.getCoordinate();
1.19 Coordinate nextRobotCoord = null;
1.20 switch (mov) {
1.21 case ABORT:
1.22 @@ -77,6 +80,16 @@
1.23 return state;
1.24 case WAIT:
1.25 break;
1.26 + case RAZOR:
1.27 + if (mine.getRazorsCount() > 0) {
1.28 + for (Cell cell : mine.getNeighboringCells(robotCell)) {
1.29 + if (cell.getContent() == WadlersBeard) {
1.30 + cell.setContent(Empty);
1.31 + }
1.32 + }
1.33 + mine.setRazorsCount(mine.getRazorsCount() - 1);
1.34 + }
1.35 + break;
1.36 case LEFT:
1.37 nextRobotCoord = robotCoord.left();
1.38 break;
1.39 @@ -106,6 +119,9 @@
1.40 lastScoreChange = score - prevScore;
1.41 state = GameState.Win;
1.42 return state;
1.43 + } else if (nextRobotCellContent == HuttonsRazor) {
1.44 + moveRobot(nextRobotCell);
1.45 + mine.setRazorsCount(mine.getRazorsCount() + 1);
1.46 } else if (robotCoord.right().equals(nextRobotCoord) && nextRobotCellContent == Rock
1.47 && getContent(mine.getCell(nextRobotCoord.right())) == Empty) {
1.48 moveRobot(nextRobotCell);
1.49 @@ -173,6 +189,24 @@
1.50 getCell(rightAndDownCoord, newCells).setContent(Rock);
1.51 } else if (getContent(curCell) == ClosedLambdaLift && mine.findCells(Lambda).size() == 0) {
1.52 getCell(curCoord, newCells).setContent(OpenLambdaLift);
1.53 + } else if (getContent(curCell) == WadlersBeard && mine.getGrowth() > 0
1.54 + && route.size() % mine.getGrowth() == 0) {
1.55 + if (getContent(leftCell) == Empty)
1.56 + getCell(leftCoord, newCells).setContent(WadlersBeard);
1.57 + if (getContent(upCell) == Empty)
1.58 + getCell(upCoord, newCells).setContent(WadlersBeard);
1.59 + if (getContent(rightCell) == Empty)
1.60 + getCell(rightCoord, newCells).setContent(WadlersBeard);
1.61 + if (getContent(downCell) == Empty)
1.62 + getCell(downCoord, newCells).setContent(WadlersBeard);
1.63 + if (getContent(leftAndUpCell) == Empty)
1.64 + getCell(leftAndUpCoord, newCells).setContent(WadlersBeard);
1.65 + if (getContent(rightAndUpCell) == Empty)
1.66 + getCell(rightAndUpCoord, newCells).setContent(WadlersBeard);
1.67 + if (getContent(leftAndDownCell) == Empty)
1.68 + getCell(leftAndDownCoord, newCells).setContent(WadlersBeard);
1.69 + if (getContent(rightAndDownCell) == Empty)
1.70 + getCell(rightAndDownCoord, newCells).setContent(WadlersBeard);
1.71 }
1.72 }
1.73 }