diff options
Diffstat (limited to 'test/jrummikub/ai/fdsolver')
-rw-r--r-- | test/jrummikub/ai/fdsolver/SolverTest.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/test/jrummikub/ai/fdsolver/SolverTest.java b/test/jrummikub/ai/fdsolver/SolverTest.java index 3798423..d03dfe4 100644 --- a/test/jrummikub/ai/fdsolver/SolverTest.java +++ b/test/jrummikub/ai/fdsolver/SolverTest.java @@ -1,8 +1,8 @@ package jrummikub.ai.fdsolver; import static org.junit.Assert.assertEquals; - -import java.util.Arrays; +import jrummikub.ai.fdsolver.constraint.LessThan; +import jrummikub.ai.fdsolver.constraint.LessThanConst; import org.junit.Test; @@ -11,18 +11,20 @@ public class SolverTest { public void test() { Solver solver = new Solver(); - Var<Integer> x = new Var<Integer>(solver, Arrays.asList(1, 2, 3)); - Var<Integer> y = Var.range(solver, 1,13); + Var<Integer> x = solver.makeVar(1, 2, 3); + Var<Integer> y = solver.makeRangeVar(1, 13); - Constraints.lessThan(solver, y, x); - - while(solver.solve()) { - solver.push(); - Constraints.lessThan(solver, x, x.getValue()); - } - solver.pop(); + solver.addConstraint(new LessThan<Integer>(false, y, x)); - assertEquals(2, (int)x.getValue()); - assertEquals(1, (int)y.getValue()); + int lastx = 0, lasty = 0; + while (solver.solve()) { + lastx = x.getValue(); + lasty = y.getValue(); + System.out.println("x = " + lastx + ", y = " + lasty); + solver.addConstraint(new LessThanConst<Integer>(false, x, x.getValue())); + } + + assertEquals(2, lastx); + assertEquals(1, lasty); } } |