Fikser et problem med roboter som står på transportbånd med en tile mellom seg og enden av kartet

This commit is contained in:
Kristian Knarvik 2020-04-23 11:30:28 +02:00
parent 3921f27b58
commit 6ac96d73e2

View File

@ -401,20 +401,20 @@ public class Board {
private boolean hasCrossingConflict(Position crossingPosition, Direction conveyorBeltDirection) { private boolean hasCrossingConflict(Position crossingPosition, Direction conveyorBeltDirection) {
Position frontLeftPosition = getNewPosition(crossingPosition, Position frontLeftPosition = getNewPosition(crossingPosition,
Direction.getLeftRotatedDirection(conveyorBeltDirection)); Direction.getLeftRotatedDirection(conveyorBeltDirection));
Tile frontLeftTile = getTileOnPosition(frontLeftPosition);
Position frontRightPosition = getNewPosition(crossingPosition, Position frontRightPosition = getNewPosition(crossingPosition,
Direction.getRightRotatedDirection(conveyorBeltDirection)); Direction.getRightRotatedDirection(conveyorBeltDirection));
Tile frontRightTile = getTileOnPosition(frontRightPosition);
Position twoForwardPosition = getNewPosition(crossingPosition, conveyorBeltDirection); Position twoForwardPosition = getNewPosition(crossingPosition, conveyorBeltDirection);
Tile twoForwardTile = getTileOnPosition(twoForwardPosition);
//If another robot is standing on a conveyor belt pointing to the tile in front, a conflict happens //If another robot is standing on a conveyor belt pointing to the tile in front, a conflict happens
return (isValidPosition(frontLeftPosition) && isConveyorBelt(frontLeftTile) && frontLeftTile.getDirection() == return (isValidPosition(frontLeftPosition) && isConveyorBelt(getTileOnPosition(frontLeftPosition)) &&
getTileOnPosition(frontLeftPosition).getDirection() ==
Direction.getRightRotatedDirection(conveyorBeltDirection) && hasRobotOnPosition(frontLeftPosition)) || Direction.getRightRotatedDirection(conveyorBeltDirection) && hasRobotOnPosition(frontLeftPosition)) ||
(isValidPosition(frontRightPosition) && isConveyorBelt(frontRightTile) (isValidPosition(frontRightPosition) && isConveyorBelt(getTileOnPosition(frontRightPosition))
&& frontRightTile.getDirection() == Direction.getLeftRotatedDirection(conveyorBeltDirection) && getTileOnPosition(frontRightPosition).getDirection() ==
Direction.getLeftRotatedDirection(conveyorBeltDirection)
&& hasRobotOnPosition(frontRightPosition)) || && hasRobotOnPosition(frontRightPosition)) ||
(isValidPosition(twoForwardPosition) && isConveyorBelt(twoForwardTile) (isValidPosition(twoForwardPosition) && isConveyorBelt(getTileOnPosition(twoForwardPosition))
&& twoForwardTile.getDirection() == Direction.getReverseDirection(conveyorBeltDirection) && getTileOnPosition(twoForwardPosition).getDirection() ==
Direction.getReverseDirection(conveyorBeltDirection)
&& hasRobotOnPosition(twoForwardPosition)); && hasRobotOnPosition(twoForwardPosition));
} }