Search in sources :

Example 1 with Operation

use of common.datastore.Operation in project solution-finder by knewjade.

the class OperationHistory method toString.

@Override
public String toString() {
    if (operationNumbers == null || operationNumbers.length < 1)
        return "";
    StringBuilder str = new StringBuilder();
    for (int i = 0; i < nextIndex; i++) {
        int history = operationNumbers[i];
        Operation operation = ActionParser.parseToOperation(history);
        str.append(operation).append(" / ");
    }
    return str.substring(0, str.length() - 3);
}
Also used : Operation(common.datastore.Operation)

Example 2 with Operation

use of common.datastore.Operation 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));
}
Also used : Order(common.datastore.order.Order) Action(common.datastore.action.Action) Piece(core.mino.Piece) SimpleOperation(common.datastore.SimpleOperation) SimpleOperation(common.datastore.SimpleOperation) Operation(common.datastore.Operation)

Example 3 with Operation

use of common.datastore.Operation 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);
}
Also used : SimpleOperation(common.datastore.SimpleOperation) SimpleOperation(common.datastore.SimpleOperation) Operation(common.datastore.Operation) Test(org.junit.jupiter.api.Test)

Example 4 with Operation

use of common.datastore.Operation 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);
}
Also used : SimpleOperation(common.datastore.SimpleOperation) SimpleOperation(common.datastore.SimpleOperation) Operation(common.datastore.Operation) Test(org.junit.jupiter.api.Test)

Example 5 with Operation

use of common.datastore.Operation 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);
}
Also used : SimpleOperation(common.datastore.SimpleOperation) SimpleOperation(common.datastore.SimpleOperation) Operation(common.datastore.Operation) Test(org.junit.jupiter.api.Test)

Aggregations

Operation (common.datastore.Operation)14 SimpleOperation (common.datastore.SimpleOperation)9 Test (org.junit.jupiter.api.Test)8 Piece (core.mino.Piece)7 Field (core.field.Field)5 MinoOperationWithKey (common.datastore.MinoOperationWithKey)4 Operations (common.datastore.Operations)4 BlockField (common.datastore.BlockField)3 Pieces (common.datastore.blocks.Pieces)3 PatternGenerator (common.pattern.PatternGenerator)3 FieldFactory (core.field.FieldFactory)3 Mino (core.mino.Mino)3 Rotate (core.srs.Rotate)3 SyntaxException (common.SyntaxException)2 BuildUpStream (common.buildup.BuildUpStream)2 OperationWithKey (common.datastore.OperationWithKey)2 Action (common.datastore.action.Action)2 LongPieces (common.datastore.blocks.LongPieces)2 Order (common.datastore.order.Order)2 OrderLookup (common.order.OrderLookup)2