use of common.datastore.SimpleOperation in project solution-finder by knewjade.
the class ActionParser method parseToOperation.
static Operation parseToOperation(int value) {
int x = value % 10;
value /= 10;
int y = value % 24;
value /= 24;
Rotate rotate = Rotate.getRotate(value % 4);
value /= 4;
Piece piece = Piece.getBlock(value);
return new SimpleOperation(piece, rotate, x, y);
}
use of common.datastore.SimpleOperation in project solution-finder by knewjade.
the class ResultHelper method createOperationStream.
public static Stream<Operation> createOperationStream(Result result) {
Order order = result.getOrder();
OperationHistory history = order.getHistory();
Stream<Operation> operationStream = history.getOperationStream();
Piece lastPiece = result.getLastPiece();
Action lastAction = result.getLastAction();
SimpleOperation lastOperation = new SimpleOperation(lastPiece, lastAction.getRotate(), lastAction.getX(), lastAction.getY());
return Stream.concat(operationStream, Stream.of(lastOperation));
}
use of common.datastore.SimpleOperation in project solution-finder by knewjade.
the class OperationComparatorTest method compare.
@Test
void compare() throws Exception {
SimpleOperation operation1 = new SimpleOperation(Piece.I, Rotate.Spawn, 0, 1);
Operation operation2 = createNewOperation(Piece.I, Rotate.Spawn, 0, 1);
OperationComparator comparator = new OperationComparator();
assertThat(comparator.compare(operation1, operation2)).isEqualTo(0);
}
use of common.datastore.SimpleOperation in project solution-finder by knewjade.
the class OperationComparatorTest method compareDiffX.
@Test
void compareDiffX() throws Exception {
SimpleOperation operation1 = new SimpleOperation(Piece.I, Rotate.Spawn, 0, 1);
Operation operation2 = createNewOperation(Piece.I, Rotate.Spawn, 7, 1);
// assert is not 0 & sign reversed
OperationComparator comparator = new OperationComparator();
assertThat(comparator.compare(operation1, operation2) * comparator.compare(operation2, operation1)).isLessThan(0);
}
use of common.datastore.SimpleOperation in project solution-finder by knewjade.
the class OperationComparatorTest method compareDiffRotate.
@Test
void compareDiffRotate() throws Exception {
SimpleOperation operation1 = new SimpleOperation(Piece.S, Rotate.Left, 0, 1);
Operation operation2 = createNewOperation(Piece.J, Rotate.Right, 7, 1);
// assert is not 0 & sign reversed
OperationComparator comparator = new OperationComparator();
assertThat(comparator.compare(operation1, operation2) * comparator.compare(operation2, operation1)).isLessThan(0);
}
Aggregations