Fikser sjekking av en robot som står på et transporbånd som peker ut av brettet, men som blir stoppet av en vegg

This commit is contained in:
Kristian Knarvik 2020-04-21 16:28:44 +02:00
parent 417681d1e2
commit ea855573e0

View File

@ -329,19 +329,18 @@ public class Board {
return true; return true;
} }
Position positionInFront = getNewPosition(conveyorBeltPosition, conveyorBeltDirection); Position positionInFront = getNewPosition(conveyorBeltPosition, conveyorBeltDirection);
if (!isValidPosition(positionInFront)) { //The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt
return true; if ((!isValidPosition(positionInFront) && moveIsStoppedByWall(conveyorBeltPosition, positionInFront,
conveyorBeltDirection)) || (isValidPosition(positionInFront) &&
!isConveyorBelt(getTileOnPosition(positionInFront)) &&
hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection))) {
return false;
} }
Tile tileInFront = getTileOnPosition(positionInFront);
//If a conveyor belt will move the robot outside the map, the move is valid //If a conveyor belt will move the robot outside the map, the move is valid
if (!isValidPosition(positionInFront)) { if (!isValidPosition(positionInFront)) {
return true; return true;
} }
//The tile in front of the robot is not a conveyor belt and has something on it stopping the conveyor belt Tile tileInFront = getTileOnPosition(positionInFront);
if (!isConveyorBelt(tileInFront) &&
hasFrontConflict(conveyorBeltPosition, positionInFront, conveyorBeltDirection)) {
return false;
}
//There is another robot trying to enter the same crossing //There is another robot trying to enter the same crossing
if (hasCrossingConflict(positionInFront, conveyorBeltDirection)) { if (hasCrossingConflict(positionInFront, conveyorBeltDirection)) {
return false; return false;