summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-06-17 17:41:52 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-06-17 17:41:52 +0200
commite06ba8ea1346e5045a34508648ac93150aacb01a (patch)
tree5d214438109aef0c622c29c8b78ab608cb1fafd8 /test
parent1b9c7c47783a0872ca3bedfad6fb120f611d354b (diff)
downloadJRummikub-e06ba8ea1346e5045a34508648ac93150aacb01a.tar
JRummikub-e06ba8ea1346e5045a34508648ac93150aacb01a.zip
Reimplemented AI (old one was too slow)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@443 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/ai/fdsolver/SolverTest.java27
-rw-r--r--test/jrummikub/model/HandTest.java91
2 files changed, 46 insertions, 72 deletions
diff --git a/test/jrummikub/ai/fdsolver/SolverTest.java b/test/jrummikub/ai/fdsolver/SolverTest.java
deleted file mode 100644
index ae32b07..0000000
--- a/test/jrummikub/ai/fdsolver/SolverTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-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());
- }
-}
diff --git a/test/jrummikub/model/HandTest.java b/test/jrummikub/model/HandTest.java
index 18db753..88ef463 100644
--- a/test/jrummikub/model/HandTest.java
+++ b/test/jrummikub/model/HandTest.java
@@ -147,13 +147,14 @@ public class HandTest {
/** */
@Test
public void testInvalid() {
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9, RED),
- new Stone(10, RED), new Stone(12, RED), new Stone(13, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
+ RED), new Stone(10, RED), new Stone(12, RED),
+ new Stone(13, RED)));
testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(10,
BLACK), new Stone(11, RED), new Stone(11, BLACK)));
- testInitialMeld(false, Arrays.asList(new Stone(10, RED),
- new Stone(10, RED), new Stone(10, BLACK), new Stone(11, RED),
- new Stone(11, BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(10,
+ RED), new Stone(10, BLACK), new Stone(11, RED), new Stone(11,
+ BLACK)));
testInitialMeld(false, Arrays.asList(new Stone(10, RED), new Stone(11,
BLACK), new Stone(12, RED)));
@@ -162,66 +163,66 @@ public class HandTest {
/** */
@Test
public void testNotEnoughPoints() {
- testInitialMeld(false,
- Arrays.asList(new Stone(8, RED), new Stone(9, RED), new Stone(10, RED)));
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
- new Stone(3, RED), new Stone(4, RED)));
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
- new Stone(3, RED), new Stone(1, BLACK), new Stone(2, BLACK), new Stone(
- 3, BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
+ RED), new Stone(10, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
+ RED), new Stone(3, RED), new Stone(4, RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
+ RED), new Stone(3, RED), new Stone(1, BLACK), new Stone(2,
+ BLACK), new Stone(3, BLACK)));
}
/** */
@Test
public void testNotEnoughPointsWithJoker() {
- testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9, RED),
- new Stone(RED), new Stone(3, BLACK)));
- testInitialMeld(false, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
- new Stone(4, BLACK), new Stone(5, BLACK), new Stone(RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(9,
+ RED), new Stone(RED), new Stone(3, BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(4, RED), new Stone(5,
+ RED), new Stone(4, BLACK), new Stone(5, BLACK), new Stone(RED)));
}
/** */
@Test
public void testNotEnoughPointsWithTwoJokers() {
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, BLUE),
- new Stone(3, BLACK), new Stone(RED), new Stone(BLACK)));
- testInitialMeld(false,
- Arrays.asList(new Stone(8, RED), new Stone(RED), new Stone(BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
+ BLUE), new Stone(3, BLACK), new Stone(RED), new Stone(BLACK)));
+ testInitialMeld(false, Arrays.asList(new Stone(8, RED), new Stone(RED),
+ new Stone(BLACK)));
}
/** */
@Test
public void testValid() {
- testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(12, RED),
- new Stone(13, RED)));
- testInitialMeld(true, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
- new Stone(6, RED), new Stone(5, ORANGE), new Stone(5, BLACK),
- new Stone(5, BLUE)));
- testInitialMeld(true, Arrays.asList(new Stone(10, RED),
- new Stone(10, BLACK), new Stone(10, ORANGE)));
+ testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(12,
+ RED), new Stone(13, RED)));
+ testInitialMeld(true, Arrays.asList(new Stone(4, RED),
+ new Stone(5, RED), new Stone(6, RED), new Stone(5, ORANGE),
+ new Stone(5, BLACK), new Stone(5, BLUE)));
+ testInitialMeld(true, Arrays.asList(new Stone(10, RED), new Stone(10,
+ BLACK), new Stone(10, ORANGE)));
}
/** */
@Test
public void testValidWithJoker() {
- testInitialMeld(true,
- Arrays.asList(new Stone(11, RED), new Stone(RED), new Stone(13, RED)));
- testInitialMeld(true, Arrays.asList(new Stone(10, RED), new Stone(BLACK),
- new Stone(10, ORANGE)));
- testInitialMeld(true, Arrays.asList(new Stone(4, RED), new Stone(5, RED),
- new Stone(6, RED), new Stone(5, BLACK), new Stone(5, BLUE), new Stone(
- RED)));
+ testInitialMeld(true, Arrays.asList(new Stone(11, RED), new Stone(RED),
+ new Stone(13, RED)));
+ testInitialMeld(true, Arrays.asList(new Stone(10, RED),
+ new Stone(BLACK), new Stone(10, ORANGE)));
+ testInitialMeld(true, Arrays.asList(new Stone(4, RED),
+ new Stone(5, RED), new Stone(6, RED), new Stone(5, BLACK),
+ new Stone(5, BLUE), new Stone(RED)));
}
/** */
@Test
public void testValidWithTwoJokers() {
- testInitialMeld(true,
- Arrays.asList(new Stone(9, RED), new Stone(RED), new Stone(BLACK)));
+ testInitialMeld(true, Arrays.asList(new Stone(9, RED), new Stone(RED),
+ new Stone(BLACK)));
}
/** */
- @Test(timeout = 1000)
+ @Test
public void testValidHuge() {
List<Stone> stones = new ArrayList<Stone>();
for (int i = 1; i <= 10; i++) {
@@ -232,15 +233,15 @@ public class HandTest {
}
/** */
- @Test(timeout = 1000)
+ @Test
public void testInvalidHuge() {
- testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2, RED),
- new Stone(4, RED), new Stone(6, RED), new Stone(8, RED), new Stone(10,
- RED), new Stone(13, RED), new Stone(1, BLACK), new Stone(2, BLACK),
- new Stone(4, BLACK), new Stone(5, BLACK), new Stone(8, BLACK),
- new Stone(9, BLACK), new Stone(12, BLACK), new Stone(3, BLUE),
- new Stone(5, BLUE), new Stone(7, BLUE), new Stone(11, BLUE), new Stone(
- RED)));
+ testInitialMeld(false, Arrays.asList(new Stone(1, RED), new Stone(2,
+ RED), new Stone(4, RED), new Stone(6, RED), new Stone(8, RED),
+ new Stone(10, RED), new Stone(13, RED), new Stone(1, BLACK),
+ new Stone(2, BLACK), new Stone(4, BLACK), new Stone(5, BLACK),
+ new Stone(8, BLACK), new Stone(9, BLACK), new Stone(12, BLACK),
+ new Stone(3, BLUE), new Stone(5, BLUE), new Stone(7, BLUE),
+ new Stone(11, BLUE), new Stone(RED)));
}
/** */