introduce bitloops
This commit is contained in:
@@ -13,6 +13,10 @@ import puzzle.Export.Rewards;
|
||||
import puzzle.Main.Opts;
|
||||
import puzzle.Masker.Clues;
|
||||
import puzzle.SwedishGenerator.Rng;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -43,7 +47,16 @@ public class MainTest {
|
||||
this.tries = 1;
|
||||
this.verbose = false;
|
||||
}};
|
||||
static final Dict dict = Dicts.loadDict(opts.wordsPath);
|
||||
static final Dict dict = loadDict(opts.wordsPath);
|
||||
public static Dict loadDict(String wordsPath) {
|
||||
var map = new LongArrayList(100_000);
|
||||
try (var lines = Files.lines(Path.of(wordsPath), StandardCharsets.UTF_8)) {
|
||||
lines.forEach(line -> CsvIndexService.lineToLemma(line, map::add));
|
||||
return Dicts.makeDict(map.toArray());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load dictionary from " + wordsPath, e);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
void testExtractSlots() {
|
||||
|
||||
@@ -173,25 +186,35 @@ public class MainTest {
|
||||
}
|
||||
@Test
|
||||
void testFiller2() {
|
||||
val mask = "1 000000\n" +
|
||||
"1 \n" +
|
||||
"1 \n" +
|
||||
"3 3 \n" +
|
||||
"3 0 3 \n" +
|
||||
"3 \n" +
|
||||
"3 \n" +
|
||||
"222 3";
|
||||
val rng = new Rng(-343913721);
|
||||
val mask = Clues.parse(
|
||||
"1 000000\n" +
|
||||
"1 \n" +
|
||||
"1 \n" +
|
||||
"3 3 \n" +
|
||||
"3 0 3 \n" +
|
||||
"3 \n" +
|
||||
"3 \n" +
|
||||
"222 3");
|
||||
Assertions.assertEquals(20, mask.clueCount());
|
||||
var slots = Masker.extractSlots(mask, dict.index());
|
||||
val slotInfo = Masker.scoreSlots(new int[slots.length], slots);
|
||||
var grid = mask.toGrid();
|
||||
var filled = fillMask(rng, slotInfo, grid, false);
|
||||
// val res = new PuzzleResult(new Clued(mask), new Gridded(grid), slotInfo, filled).exportFormatFromFilled(0, new Rewards(0, 0, 0));
|
||||
}
|
||||
@Test
|
||||
void testFiller() {
|
||||
val rng = new Rng(-343913721);
|
||||
val mask = new Clues(
|
||||
74732156493031040L,
|
||||
193L,
|
||||
281475397248512L,
|
||||
128L,
|
||||
422762372923520L,
|
||||
192L);
|
||||
val mask = Clues.parse(
|
||||
" 3 300\n" +
|
||||
" 1 \n" +
|
||||
" 1 \n" +
|
||||
" 3 0 \n" +
|
||||
" 31 \n" +
|
||||
" 1 \n" +
|
||||
" 1 2\n" +
|
||||
"21 22 3");
|
||||
var slots = Masker.extractSlots(mask, dict.index());
|
||||
val slotInfo = Masker.scoreSlots(new int[slots.length], slots);
|
||||
var grid = mask.toGrid();
|
||||
@@ -204,6 +227,7 @@ public class MainTest {
|
||||
var g = new Gridded(grid);
|
||||
g.gridToString(mask);
|
||||
var aa = new PuzzleResult(new Clued(mask), g, slotInfo, filled).exportFormatFromFilled(1, new Rewards(1, 1, 1));
|
||||
System.out.println(String.join("\n", aa.grid()));
|
||||
|
||||
}
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user