use of common.datastore.action.MinimalAction in project solution-finder by knewjade.
the class MinoTransform method enumerateOthers.
List<Action> enumerateOthers(int x, int y, Rotate rotate) {
List<Action> actions = new ArrayList<>();
int currentRotateIndex = rotate.getNumber();
int newX = x + this.offsetsX[currentRotateIndex];
int newY = y + offsetsY[currentRotateIndex];
for (Rotate prevRotate : reverseMap.get(rotate)) {
int index = prevRotate.getNumber();
MinimalAction action = MinimalAction.create(newX - this.offsetsX[index], newY - offsetsY[index], prevRotate);
actions.add(action);
}
return actions;
}
use of common.datastore.action.MinimalAction in project solution-finder by knewjade.
the class OperationHistoryTest method random.
@Test
void random() throws ExecutionException, InterruptedException {
Randoms randoms = new Randoms();
for (int count = 0; count < 1000; count++) {
int size = randoms.nextInt(1, 10);
ArrayList<Operation> operations = new ArrayList<>();
OperationHistory history = new OperationHistory(size);
for (int index = 0; index < size; index++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int y = randoms.nextInt(4);
int x = randoms.nextInt(10);
MinimalAction action = MinimalAction.create(x, y, rotate);
history = history.recordAndReturnNew(piece, action);
operations.add(new SimpleOperation(piece, rotate, x, y));
}
List<Operation> actual = history.getOperationStream().collect(Collectors.toList());
assertThat(actual).isEqualTo(operations);
}
}
use of common.datastore.action.MinimalAction in project solution-finder by knewjade.
the class PassedMinoShifterTest method createTransformedAction.
@Test
void createTransformedAction() {
Randoms randoms = new Randoms();
PassedMinoShifter minoShifter = new PassedMinoShifter();
for (int count = 0; count < 10000; count++) {
Piece piece = randoms.block();
Rotate rotate = randoms.rotate();
int x = randoms.nextInt(10);
int y = randoms.nextInt(0, 12);
MinimalAction action = MinimalAction.create(x, y, rotate);
Action actualAction = minoShifter.createTransformedAction(piece, action);
assertThat(actualAction).isEqualTo(action);
}
}
Aggregations