[WIP, BROKEN] Plug the stub for the Hypothesis solver to show how it'll be used
This commit is contained in:
parent
fb0c655089
commit
e8d0db8b1d
2 changed files with 24 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import * as CellSet from Geometry.CellSet;
|
|
||||||
import set from Grid.Util;
|
import set from Grid.Util;
|
||||||
|
import * as Hypothesis from Solver.Hypothesis;
|
||||||
import * as Inclusion from Solver.Inclusion;
|
import * as Inclusion from Solver.Inclusion;
|
||||||
import * as SingleCell from Solver.SingleCell;
|
import * as SingleCell from Solver.SingleCell;
|
||||||
import * as State from Solver.State;
|
import * as State from Solver.State;
|
||||||
|
@ -30,7 +30,8 @@ function rate(coloring) {
|
||||||
function findNextStep(solvingState) {
|
function findNextStep(solvingState) {
|
||||||
return Strategy.tryEach([
|
return Strategy.tryEach([
|
||||||
Inclusion.find(solvingState),
|
Inclusion.find(solvingState),
|
||||||
SingleCell.find(solvingState)
|
SingleCell.find(solvingState),
|
||||||
|
Hypothesis.find(solvingState)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
js/Solver/Hypothesis.js
Normal file
21
js/Solver/Hypothesis.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import perimeter from Solver.SingleCell;
|
||||||
|
import * as State from Solver.State;
|
||||||
|
|
||||||
|
return {
|
||||||
|
find: find
|
||||||
|
};
|
||||||
|
|
||||||
|
function find(solvingState) {
|
||||||
|
solvingState.missing.map(f(solvingState))
|
||||||
|
};
|
||||||
|
|
||||||
|
function f(solvingState) {
|
||||||
|
return function(cell) {
|
||||||
|
var forked = State.fork(solvingState);
|
||||||
|
State.set(forked, cell, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkContradiction(beforeState, afterState, cell) {
|
||||||
|
//TODO has one cellSet (color, row, column) become empty ? if it doesn't contain cell, it's a contradiction
|
||||||
|
}
|
Loading…
Reference in a new issue