Add tests

This commit is contained in:
2024-06-23 22:27:45 +02:00
parent a598218cf2
commit f76be158a0
7 changed files with 258 additions and 57 deletions

View File

@@ -41,6 +41,7 @@ fun generateGame(size: Int = 6): Game {
// (You can speed this up by removing clues in batches rather than one at a time, but it makes the algorithm more complicated to describe.)
}
// FIXME: I need to better include the options into the solver (rule violations checks)
private fun solve(
grid: Grid,
clues: Collection<Clue>
@@ -121,13 +122,11 @@ fun <C : ItemClass<C>> GameRow<C>.cleanupOptions(cell: GameCell<C>) {
private fun getAllClues(rows: List<List<Item<ItemClass<*>>>>): MutableSet<Clue> {
val clues = mutableSetOf<Clue>()
// rows.forEach { row ->
// row.forEachIndexed { i, item ->
// clues.add(PositionClue(item, i))
// }
// }
clues.add(PositionClue(rows.random().first(), 0))
clues.add(PositionClue(rows.random()[3], 3))
rows.forEach { row ->
row.forEachIndexed { i, item ->
clues.add(PositionClue(item, i))
}
}
rows.forEach { columns ->
columns.forEachIndexed { j, item ->