Permalink
Browse files

Before adding dll to the project

  • Loading branch information...
Kestutis-Z
Kestutis-Z committed Nov 9, 2012
1 parent 1467ad7 commit 40fdcfe66609f5afe7f9a8c47f5a387a9646d67a
Showing with 300 additions and 35 deletions.
  1. +1 −0 endgame-oracle/pom.xml
  2. +2 −2 endgame-oracle/src/main/java/tablebases/GaviotaTablebasesLibrary.java
  3. +192 −0 endgame-oracle/src/test/java/tablebases/GaviotaTablebasesProbingCodeAPITest.java
  4. BIN endgame-oracle/target/classes/tablebases/GaviotaTablebasesLibrary.class
  5. +4 −4 endgame-oracle/target/surefire-reports/TEST-chess.ChessPositionDiagramTest.xml
  6. +8 −7 endgame-oracle/target/surefire-reports/TEST-chess.ChessPositionTest.xml
  7. +2 −2 endgame-oracle/target/surefire-reports/TEST-chess.PieceTest.xml
  8. +10 −10 endgame-oracle/target/surefire-reports/TEST-chess.SquareTest.xml
  9. +67 −0 endgame-oracle/target/surefire-reports/TEST-tablebases.GaviotaTablebasesProbingCodeAPITest.xml
  10. +2 −2 endgame-oracle/target/surefire-reports/TEST-tablebases.GaviotaTablebasesQueryTemplateTest.xml
  11. +2 −2 endgame-oracle/target/surefire-reports/TEST-tablebases.TablebaseTest.xml
  12. +1 −1 endgame-oracle/target/surefire-reports/chess.ChessPositionDiagramTest.txt
  13. +1 −1 endgame-oracle/target/surefire-reports/chess.ChessPositionTest.txt
  14. +1 −1 endgame-oracle/target/surefire-reports/chess.PieceTest.txt
  15. +1 −1 endgame-oracle/target/surefire-reports/chess.SquareTest.txt
  16. +4 −0 endgame-oracle/target/surefire-reports/tablebases.GaviotaTablebasesProbingCodeAPITest.txt
  17. +1 −1 endgame-oracle/target/surefire-reports/tablebases.GaviotaTablebasesQueryTemplateTest.txt
  18. +1 −1 endgame-oracle/target/surefire-reports/tablebases.TablebaseTest.txt
  19. BIN endgame-oracle/target/test-classes/tablebases/GaviotaTablebasesProbingCodeAPITest.class
View
@@ -29,5 +29,6 @@ A program to experiment with chess endgame tablebases and machine learning algor
<version>1.9.5</version>
<scope>test</scope>
</dependency>
+
</dependencies>
</project>
@@ -13,9 +13,9 @@
static {
try {
- System.loadLibrary("GaviotaTablebasesLibrary");
+ System.loadLibrary("GaviotaTablebasesProbingAPI");
} catch (Exception e) {
- System.out.println("GaviotaTablebasesLibrary could not be loaded.");
+ System.out.println("GaviotaTablebasesProbingAPI could not be loaded.");
e.printStackTrace();
}
}
@@ -0,0 +1,192 @@
+package tablebases;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.mockito.Mockito.*;
+
+import chess.ChessPosition;
+import chess.ChessPositionDiagram;
+import chess.ChessPositionEvaluation;
+import chess.IncorrectChessDiagramDrawingException;
+import chess.SideToMove;
+import chess.Square;
+
+public class GaviotaTablebasesProbingCodeAPITest {
+
+ //private static final String GTB_PATH = System.getProperty("user.dir") + "/Gaviota Tablebases";
+ private static final String GTB_PATH = "C:/Users/Kestutis/Gaviota Tablebases";
+ private GaviotaTablebasesLibrary mockedGTB;
+ private ChessPosition chessPositionIllegal, chessPositionKK, chessPositionKRK;
+ private EndgameTablebasesProbingCodeAPI endtablebases;
+
+ @BeforeClass
+ public static void intGTB() {
+ GaviotaTablebasesLibrary.initializeGaviotaTablebases(GTB_PATH);
+ }
+
+ @Before
+ public void set() throws IncorrectChessDiagramDrawingException {
+ mockedGTB = mock(GaviotaTablebasesLibrary.class);
+
+ List<Square> squaresIL = new ArrayList<Square>();
+ squaresIL.add(Square.A7);
+ squaresIL.add(Square.E7);
+ squaresIL.add(Square.A8);
+ chessPositionIllegal = ChessPosition.createFromTablebase(
+ Tablebase.KPK, squaresIL, SideToMove.BLACK);
+
+ List<Square> squaresKK = new ArrayList<Square>();
+ squaresKK.add(Square.E7);
+ squaresKK.add(Square.A8);
+ chessPositionKK = ChessPosition.createFromTablebase(
+ Tablebase.KK, squaresKK, SideToMove.WHITE);
+
+ List<Square> squaresKRK = new ArrayList<Square>();
+ squaresKRK.add(Square.C1);
+ squaresKRK.add(Square.E7);
+ squaresKRK.add(Square.A8);
+ chessPositionKRK = ChessPosition.createFromTablebase(
+ Tablebase.KRK, squaresKRK, SideToMove.WHITE);
+ /*
+ String drawingKPK =
+
+ " _______________________________________________________ \n" +
+ " | | | | | | | | | \n" +
+ " 8| BK | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 7| | | | | WP | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 6| WK | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 5| | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 4| | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 3| | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 2| | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " | | | | | | | | | \n" +
+ " 1| | | | | | | | | \n" +
+ " |______|______|______|______|______|______|______|______| \n" +
+ " a b c d e f g h \n" ;
+
+ ChessPositionDiagram diagram = ChessPositionDiagram.createFromTextDiagram(drawingKPK);
+ chessPositionIllegal = ChessPosition.createFromTextualDrawing(diagram, SideToMove.BLACK);
+ */
+ endtablebases = new GaviotaTablebasesProbingCodeAPI();
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void initializeGTBMethodMockTest() {
+ doThrow(new RuntimeException()).when(mockedGTB);
+ verify(mockedGTB);
+ }
+
+ @Test
+ public void queryGaviotaTablebasesForResultOnlyTest() {
+ /*
+ ChessPositionEvaluation expectedResult1 = ChessPositionEvaluation.ILLEGAL;
+ ChessPositionEvaluation actualResult1 = endtablebases.queryTablebaseForResultOnly(chessPositionIllegal);
+ assertEquals(expectedResult1, actualResult1);
+ */
+ ChessPositionEvaluation expectedResult2 = ChessPositionEvaluation.DRAW;
+ ChessPositionEvaluation actualResult2 = endtablebases.queryTablebaseForResultOnly(chessPositionKK);
+ assertEquals(expectedResult2, actualResult2);
+
+ ChessPositionEvaluation expectedResult3 = ChessPositionEvaluation.WHITE_WINS;
+ ChessPositionEvaluation actualResult3 = endtablebases.queryTablebaseForResultOnly(chessPositionKRK);
+ assertEquals(expectedResult3, actualResult3);
+ }
+
+ @Test
+ public void queryGaviotaTablebasesForResultAndDtmTest() {
+ ChessPositionEvaluation expectedResult1 = ChessPositionEvaluation.ILLEGAL;
+ ChessPositionEvaluation actualResult1 = endtablebases.queryTablebaseForResultOnly(chessPositionIllegal);
+ assertEquals(expectedResult1, actualResult1);
+
+ int expectedDtm1 = 0;
+ int actualDtm1 = endtablebases.queryTablebaseForResultAndDTM(chessPositionIllegal).getDistanceToMate();
+ assertEquals(expectedDtm1, actualDtm1);
+
+ ChessPositionEvaluation expectedResult2 = ChessPositionEvaluation.DRAW;
+ ChessPositionEvaluation actualResult2 = endtablebases.queryTablebaseForResultOnly(chessPositionKK);
+ assertEquals(expectedResult2, actualResult2);
+
+ int expectedDtm2 = 0;
+ int actualDtm2 = endtablebases.queryTablebaseForResultAndDTM(chessPositionKK).getDistanceToMate();
+ assertEquals(expectedDtm2, actualDtm2);
+
+ ChessPositionEvaluation expectedResult3 = ChessPositionEvaluation.WHITE_WINS;
+ ChessPositionEvaluation actualResult3 = endtablebases.queryTablebaseForResultOnly(chessPositionKRK);
+ assertEquals(expectedResult3, actualResult3);
+
+ int expectedDtm3 = 10;
+ int actualDtm3 = endtablebases.queryTablebaseForResultAndDTM(chessPositionKRK).getDistanceToMate();
+ assertEquals(expectedDtm3, actualDtm3);
+
+ List<Square> squares4 = new ArrayList<Square>();
+ squares4.add(Square.G7);
+ squares4.add(Square.E3);
+ squares4.add(Square.B2);
+ ChessPosition cp4 = ChessPosition.createFromTablebase(
+ Tablebase.KRK, squares4, SideToMove.BLACK);
+ int expectedDtm4 = 12;
+ int actualDtm4 = endtablebases.queryTablebaseForResultAndDTM(cp4).getDistanceToMate();
+ assertEquals(expectedDtm4, actualDtm4);
+
+ List<Square> squares5 = new ArrayList<Square>();
+ squares5.add(Square.G7);
+ squares5.add(Square.G2);
+ squares5.add(Square.B2);
+ ChessPosition cp5 = ChessPosition.createFromTablebase(
+ Tablebase.KPK, squares5, SideToMove.BLACK);
+ int expectedDtm5 = 13;
+ int actualDtm5 = endtablebases.queryTablebaseForResultAndDTM(cp5).getDistanceToMate();
+ assertEquals(expectedDtm5, actualDtm5);
+
+ List<Square> squares6 = new ArrayList<Square>();
+ squares6.add(Square.D5);
+ squares6.add(Square.D3);
+ squares6.add(Square.B7);
+ ChessPosition cp6 = ChessPosition.createFromTablebase(
+ Tablebase.KPK, squares6, SideToMove.BLACK);
+ int expectedDtm6 = 16;
+ int actualDtm6 = endtablebases.queryTablebaseForResultAndDTM(cp6).getDistanceToMate();
+ assertEquals(expectedDtm6, actualDtm6);
+ }
+
+
+ /*
+ @Test
+ public void testQueryTablebaseForResultOnly() {
+ ChessPositionEvaluation expectedResult1 = ChessPositionEvaluation.ILLEGAL;
+ ChessPositionEvaluation actualResult1 = endtablebases.queryTablebaseForResultOnly(chessPositionIllegal);
+ assertEquals(expectedResult1, actualResult1);
+ }
+
+ @Test
+ public void testQueryTablebaseForResultAndDTM() {
+ System.out.println("GaviotaTablebasesProbingAPI could not be loaded.");
+ }
+ */
+
+
+
+}
+
+
+
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite failures="0" time="0.104" errors="0" skipped="0" tests="2" name="chess.ChessPositionDiagramTest">
+<testsuite failures="0" time="0.155" errors="0" skipped="0" tests="2" name="chess.ChessPositionDiagramTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.7.0\jre\bin"/>
@@ -27,7 +27,7 @@
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 7"/>
- <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf513400212972208422.tmp"/>
+ <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf7328368529512919500.tmp"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.library.path" value="C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.7.0\bin;C:\Python27\Lib\site-packages\PyQt4\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Borland\BCC55\Bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Java\jdk1.7.0\bin;%M2_HOME%\bin;C:\Program Files\Java\jdk1.6.0_26\bin;C:\MinGW\bin;C:\Users\Kestutis\Downloads\apache-maven-3.0.4-bin (1)\bin;;C:\Users\Kestutis\eclipse;;."/>
<property name="java.specification.name" value="Java Platform API Specification"/>
@@ -61,6 +61,6 @@
<property name="sun.desktop" value="windows"/>
<property name="sun.cpu.isalist" value="amd64"/>
</properties>
- <testcase time="0.04" classname="chess.ChessPositionDiagramTest" name="testGetChessPositionDiagram"/>
- <testcase time="0" classname="chess.ChessPositionDiagramTest" name="testGetPiecesWithSquares"/>
+ <testcase time="0" classname="chess.ChessPositionDiagramTest" name="testGetChessPositionDiagram"/>
+ <testcase time="0.026" classname="chess.ChessPositionDiagramTest" name="testGetPiecesWithSquares"/>
</testsuite>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite failures="0" time="0.359" errors="0" skipped="0" tests="8" name="chess.ChessPositionTest">
+<testsuite failures="0" time="0.356" errors="0" skipped="0" tests="9" name="chess.ChessPositionTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.7.0\jre\bin"/>
@@ -27,7 +27,7 @@
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 7"/>
- <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf513400212972208422.tmp"/>
+ <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf7328368529512919500.tmp"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.library.path" value="C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.7.0\bin;C:\Python27\Lib\site-packages\PyQt4\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Borland\BCC55\Bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Java\jdk1.7.0\bin;%M2_HOME%\bin;C:\Program Files\Java\jdk1.6.0_26\bin;C:\MinGW\bin;C:\Users\Kestutis\Downloads\apache-maven-3.0.4-bin (1)\bin;;C:\Users\Kestutis\eclipse;;."/>
<property name="java.specification.name" value="Java Platform API Specification"/>
@@ -61,12 +61,13 @@
<property name="sun.desktop" value="windows"/>
<property name="sun.cpu.isalist" value="amd64"/>
</properties>
- <testcase time="0.312" classname="chess.ChessPositionTest" name="testGetBlackPieces"/>
- <testcase time="0" classname="chess.ChessPositionTest" name="testGetWhiteSquares"/>
- <testcase time="0.047" classname="chess.ChessPositionTest" name="testGetPiecesAndSquaresMap"/>
- <testcase time="0" classname="chess.ChessPositionTest" name="testCreateFromTextualDrawing"/>
+ <testcase time="0.298" classname="chess.ChessPositionTest" name="testGetBlackPieces"/>
+ <testcase time="0.001" classname="chess.ChessPositionTest" name="testCreateFromTextDiagramThrowsIncorrectChessDiagramDrawingException"/>
+ <testcase time="0.001" classname="chess.ChessPositionTest" name="testGetWhiteSquares"/>
+ <testcase time="0.041" classname="chess.ChessPositionTest" name="testGetPiecesAndSquaresMap"/>
+ <testcase time="0.012" classname="chess.ChessPositionTest" name="testCreateFromTextualDrawing"/>
<testcase time="0" classname="chess.ChessPositionTest" name="testGetPiecesToSquaresThrowsIllegalArgumentException"/>
<testcase time="0" classname="chess.ChessPositionTest" name="testGetSquaresToPiecesMapThrowsIllegalArgumentException"/>
<testcase time="0" classname="chess.ChessPositionTest" name="testGetWhitePieces"/>
- <testcase time="0" classname="chess.ChessPositionTest" name="testGetBlackSquares"/>
+ <testcase time="0.001" classname="chess.ChessPositionTest" name="testGetBlackSquares"/>
</testsuite>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite failures="0" time="0" errors="0" skipped="0" tests="3" name="chess.PieceTest">
+<testsuite failures="0" time="0.001" errors="0" skipped="0" tests="3" name="chess.PieceTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.7.0\jre\bin"/>
@@ -27,7 +27,7 @@
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 7"/>
- <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf513400212972208422.tmp"/>
+ <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf7328368529512919500.tmp"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.library.path" value="C:\Program Files\Java\jdk1.7.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.7.0\bin;C:\Python27\Lib\site-packages\PyQt4\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Borland\BCC55\Bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Java\jdk1.7.0\bin;%M2_HOME%\bin;C:\Program Files\Java\jdk1.6.0_26\bin;C:\MinGW\bin;C:\Users\Kestutis\Downloads\apache-maven-3.0.4-bin (1)\bin;;C:\Users\Kestutis\eclipse;;."/>
<property name="java.specification.name" value="Java Platform API Specification"/>
Oops, something went wrong.

0 comments on commit 40fdcfe

Please sign in to comment.