use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class ForwardOrderLookUpTest method parseOverBlocksRandom.
@Test
void parseOverBlocksRandom() throws Exception {
Randoms randoms = new Randoms();
for (int size = 3; size <= 15; size++) {
List<Piece> pieces = randoms.blocks(size);
int toDepth = pieces.size();
ForwardOrderLookUp lookUp = new ForwardOrderLookUp(toDepth - 1, pieces.size());
HashSet<LongPieces> forward = lookUp.parse(pieces).map(LongPieces::new).collect(Collectors.toCollection(HashSet::new));
for (int count = 0; count < 10000; count++) {
ArrayList<Piece> sample = new ArrayList<>();
int holdIndex = 0;
for (int index = 1; index < size; index++) {
if (randoms.nextBoolean(0.3)) {
// そのまま追加
sample.add(pieces.get(index));
} else {
// ホールドを追加
sample.add(pieces.get(holdIndex));
holdIndex = index;
}
}
assertThat(new LongPieces(sample)).isIn(forward);
}
}
}
use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class HoldBreakEnumeratePieces method enumerate.
@Override
public Set<LongPieces> enumerate() throws IOException {
assert counter == -1;
int depth = generator.getDepth();
ForwardOrderLookUp forwardOrderLookUp = new ForwardOrderLookUp(maxDepth, depth);
AtomicInteger counter = new AtomicInteger();
HashSet<LongPieces> searchingPieces = create(depth, forwardOrderLookUp, counter);
this.counter = counter.get();
return searchingPieces;
}
use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class NormalEnumeratePieces method enumerate.
@Override
public Set<LongPieces> enumerate() {
assert counter == -1;
int depth = generator.getDepth();
AtomicInteger counter = new AtomicInteger();
HashSet<LongPieces> searchingPieces = create(depth, counter);
this.counter = counter.get();
return searchingPieces;
}
use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class OrderLookupTest method reverseJustBlocksRandom.
@Test
void reverseJustBlocksRandom() throws Exception {
Randoms randoms = new Randoms();
for (int size = 1; size <= 13; size++) {
List<Piece> pieceList = randoms.blocks(size);
int fromDepth = pieceList.size();
PiecesNumberComparator comparator = new PiecesNumberComparator();
List<LongPieces> forward1 = OrderLookup.reverseBlocks(pieceList, fromDepth).stream().map(StackOrder::toList).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
ReverseOrderLookUp lookUp = new ReverseOrderLookUp(pieceList.size(), fromDepth);
List<LongPieces> forward2 = lookUp.parse(pieceList).map(blockStream -> blockStream.collect(Collectors.toList())).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
assertThat(forward2).isEqualTo(forward1);
}
}
use of common.datastore.blocks.LongPieces in project solution-finder by knewjade.
the class OrderLookupTest method forwardOverBlocksRandom.
@Test
void forwardOverBlocksRandom() throws Exception {
Randoms randoms = new Randoms();
for (int size = 3; size <= 13; size++) {
List<Piece> pieceList = randoms.blocks(size);
int toDepth = pieceList.size() - 1;
PiecesNumberComparator comparator = new PiecesNumberComparator();
List<LongPieces> forward1 = OrderLookup.forwardBlocks(pieceList, toDepth).stream().map(StackOrder::toList).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
ForwardOrderLookUp lookUp = new ForwardOrderLookUp(toDepth, pieceList.size());
List<LongPieces> forward2 = lookUp.parse(pieceList).map(blockStream -> blockStream.collect(Collectors.toList())).map(LongPieces::new).sorted(comparator).collect(Collectors.toList());
assertThat(forward2).isEqualTo(forward1);
}
}
Aggregations