icfp-model/src/main/java/ru/bosony/model/game/Game.java
changeset 30 666821484adc
parent 29 66aa96e8fd92
child 47 b3d48e364f9e
     1.1 --- a/icfp-model/src/main/java/ru/bosony/model/game/Game.java	Mon Jul 16 00:05:50 2012 +0400
     1.2 +++ b/icfp-model/src/main/java/ru/bosony/model/game/Game.java	Mon Jul 16 01:46:54 2012 +0400
     1.3 @@ -3,11 +3,12 @@
     1.4  import static ru.bosony.model.cellscontents.CellContent.ClosedLambdaLift;
     1.5  import static ru.bosony.model.cellscontents.CellContent.Earth;
     1.6  import static ru.bosony.model.cellscontents.CellContent.Empty;
     1.7 +import static ru.bosony.model.cellscontents.CellContent.HighOrderRock;
     1.8 +import static ru.bosony.model.cellscontents.CellContent.HuttonsRazor;
     1.9  import static ru.bosony.model.cellscontents.CellContent.Lambda;
    1.10  import static ru.bosony.model.cellscontents.CellContent.MiningRobot;
    1.11  import static ru.bosony.model.cellscontents.CellContent.OpenLambdaLift;
    1.12  import static ru.bosony.model.cellscontents.CellContent.Rock;
    1.13 -import static ru.bosony.model.cellscontents.CellContent.HuttonsRazor;
    1.14  import static ru.bosony.model.cellscontents.CellContent.WadlersBeard;
    1.15  
    1.16  import java.util.ArrayList;
    1.17 @@ -130,6 +131,14 @@
    1.18  				&& getContent(mine.getCell(nextRobotCoord.left())) == Empty) {
    1.19  			moveRobot(nextRobotCell);
    1.20  			mine.getCell(nextRobotCoord.left()).setContent(Rock);
    1.21 +		} else if (robotCoord.right().equals(nextRobotCoord) && nextRobotCellContent == HighOrderRock
    1.22 +				&& getContent(mine.getCell(nextRobotCoord.right())) == Empty) {
    1.23 +			moveRobot(nextRobotCell);
    1.24 +			mine.getCell(nextRobotCoord.right()).setContent(HighOrderRock);
    1.25 +		} else if (robotCoord.left().equals(nextRobotCoord) && nextRobotCellContent == HighOrderRock
    1.26 +				&& getContent(mine.getCell(nextRobotCoord.left())) == Empty) {
    1.27 +			moveRobot(nextRobotCell);
    1.28 +			mine.getCell(nextRobotCoord.left()).setContent(HighOrderRock);
    1.29  		} else if (CellContent.getTrampolines().contains(nextRobotCellContent)
    1.30  				&& CellContent.getTargets().contains(nextRobotCellContent.getTrampolineTarget())) {
    1.31  			CellContent trampoline = nextRobotCellContent;
    1.32 @@ -174,20 +183,53 @@
    1.33  				if (getContent(curCell) == Rock && getContent(downCell) == Empty) {
    1.34  					getCell(curCoord, newCells).setContent(Empty);
    1.35  					getCell(downCoord, newCells).setContent(Rock);
    1.36 -				} else if (getContent(curCell) == Rock && getContent(downCell) == Rock
    1.37 +				} else if (getContent(curCell) == HighOrderRock && getContent(downCell) == Empty) {
    1.38 +					getCell(curCoord, newCells).setContent(Empty);
    1.39 +					if (getContent(mine.getCell(downCoord.down())) != Empty)
    1.40 +						getCell(downCoord, newCells).setContent(Lambda);
    1.41 +					else
    1.42 +						getCell(downCoord, newCells).setContent(HighOrderRock);
    1.43 +				} else if (getContent(curCell) == Rock
    1.44 +						&& (getContent(downCell) == Rock || getContent(downCell) == HighOrderRock)
    1.45  						&& getContent(rightCell) == Empty && getContent(rightAndDownCell) == Empty) {
    1.46  					getCell(curCoord, newCells).setContent(Empty);
    1.47  					getCell(rightAndDownCoord, newCells).setContent(Rock);
    1.48 -				} else if (getContent(curCell) == Rock && getContent(downCell) == Rock
    1.49 +				} else if (getContent(curCell) == HighOrderRock
    1.50 +						&& (getContent(downCell) == Rock || getContent(downCell) == HighOrderRock)
    1.51 +						&& getContent(rightCell) == Empty && getContent(rightAndDownCell) == Empty) {
    1.52 +					getCell(curCoord, newCells).setContent(Empty);
    1.53 +					if (getContent(mine.getCell(rightAndDownCoord.down())) != Empty)
    1.54 +						getCell(rightAndDownCoord, newCells).setContent(Lambda);
    1.55 +					else
    1.56 +						getCell(rightAndDownCoord, newCells).setContent(HighOrderRock);
    1.57 +				} else if (getContent(curCell) == Rock
    1.58 +						&& (getContent(downCell) == Rock || getContent(downCell) == HighOrderRock)
    1.59  						&& (getContent(rightCell) != Empty || getContent(rightAndDownCell) != Empty)
    1.60  						&& getContent(leftCell) == Empty && getContent(leftAndDownCell) == Empty) {
    1.61  					getCell(curCoord, newCells).setContent(Empty);
    1.62  					getCell(leftAndDownCoord, newCells).setContent(Rock);
    1.63 +				} else if (getContent(curCell) == HighOrderRock
    1.64 +						&& (getContent(downCell) == Rock || getContent(downCell) == HighOrderRock)
    1.65 +						&& (getContent(rightCell) != Empty || getContent(rightAndDownCell) != Empty)
    1.66 +						&& getContent(leftCell) == Empty && getContent(leftAndDownCell) == Empty) {
    1.67 +					getCell(curCoord, newCells).setContent(Empty);
    1.68 +					if (getContent(mine.getCell(leftAndDownCoord.down())) != Empty)
    1.69 +						getCell(leftAndDownCoord, newCells).setContent(Lambda);
    1.70 +					else
    1.71 +						getCell(leftAndDownCoord, newCells).setContent(HighOrderRock);
    1.72  				} else if (getContent(curCell) == Rock && getContent(downCell) == Lambda
    1.73  						&& getContent(rightCell) == Empty && getContent(rightAndDownCell) == Empty) {
    1.74  					getCell(curCoord, newCells).setContent(Empty);
    1.75  					getCell(rightAndDownCoord, newCells).setContent(Rock);
    1.76 -				} else if (getContent(curCell) == ClosedLambdaLift && mine.findCells(Lambda).size() == 0) {
    1.77 +				} else if (getContent(curCell) == HighOrderRock && getContent(downCell) == Lambda
    1.78 +						&& getContent(rightCell) == Empty && getContent(rightAndDownCell) == Empty) {
    1.79 +					getCell(curCoord, newCells).setContent(Empty);
    1.80 +					if (getContent(mine.getCell(rightAndDownCoord.down())) != Empty)
    1.81 +						getCell(rightAndDownCoord, newCells).setContent(Lambda);
    1.82 +					else
    1.83 +						getCell(rightAndDownCoord, newCells).setContent(HighOrderRock);
    1.84 +				} else if (getContent(curCell) == ClosedLambdaLift
    1.85 +						&& mine.getLambdasAndHighOrderRocksStartCount() == lambdaCollectedCount) {
    1.86  					getCell(curCoord, newCells).setContent(OpenLambdaLift);
    1.87  				} else if (getContent(curCell) == WadlersBeard && mine.getGrowth() > 0
    1.88  						&& route.size() % mine.getGrowth() == 0) {
    1.89 @@ -213,7 +255,11 @@
    1.90  
    1.91  		// Other ending conditions
    1.92  		robotCoord = mine.getRobotCell().getCoordinate();
    1.93 -		if (getContent(mine.getCell(robotCoord.up())) != Rock && getContent(getCell(robotCoord.up(), newCells)) == Rock) {
    1.94 +		if (getContent(mine.getCell(robotCoord.up())) != Rock && getContent(getCell(robotCoord.up(), newCells)) == Rock
    1.95 +				|| getContent(mine.getCell(robotCoord.up())) != HighOrderRock
    1.96 +				&& getContent(getCell(robotCoord.up(), newCells)) == HighOrderRock
    1.97 +				|| getContent(mine.getCell(robotCoord.up())) == Empty
    1.98 +				&& getContent(getCell(robotCoord.up(), newCells)) == Lambda) {
    1.99  			mine.setCells(newCells);
   1.100  
   1.101  			lastScoreChange = score - prevScore;