blob: ae32b07695f7654266c51997f53705b441f8c7a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package jrummikub.ai.fdsolver;
import static org.junit.Assert.assertEquals;
import jrummikub.ai.fdsolver.constraint.LessThan;
import jrummikub.ai.fdsolver.constraint.LessThanConst;
import org.junit.Test;
public class SolverTest {
@Test
public void test() {
Solver solver = new Solver();
Var<Integer> x = solver.makeVar(1, 2, 3);
Var<Integer> y = solver.makeRangeVar(1, 13);
solver.addConstraint(new LessThan<Integer>(false, y, x));
while (solver.solve()) {
solver.record();
solver.addConstraint(new LessThanConst<Integer>(false, x, x.getValue()));
}
solver.restore();
assertEquals(2, (int)x.getValue());
assertEquals(1, (int)y.getValue());
}
}
|