Skip to content
This repository
Browse code

All ChessPosition and Square tests passed

  • Loading branch information...
commit 8d444fee9a6b0c69c11ba6daecfcb7a794593bd2 1 parent a6c6c66
Kestutis-Z authored November 06, 2012

Showing 24 changed files with 1,062 additions and 6 deletions. Show diff stats Hide diff stats

  1. 142  endgame-oracle/src/main/java/chess/ChessPosition.java
  2. 37  endgame-oracle/src/main/java/chess/ChessPositionEvaluation.java
  3. 7  endgame-oracle/src/main/java/chess/SideToMove.java
  4. 221  endgame-oracle/src/main/java/chess/Square.java
  5. 12  endgame-oracle/src/main/java/chess/SquareContainsNoPiecesException.java
  6. 13  endgame-oracle/src/main/java/chess/SquareHasNoAdjacentSquareException.java
  7. 174  endgame-oracle/src/test/java/chess/ChessPositionTest.java
  8. 287  endgame-oracle/src/test/java/chess/SquareTest.java
  9. BIN  endgame-oracle/target/classes/chess/ChessPosition.class
  10. BIN  endgame-oracle/target/classes/chess/ChessPositionEvaluation$ChessPositionEvaluationWithDTM.class
  11. BIN  endgame-oracle/target/classes/chess/ChessPositionEvaluation.class
  12. BIN  endgame-oracle/target/classes/chess/SideToMove.class
  13. BIN  endgame-oracle/target/classes/chess/Square$Direction.class
  14. BIN  endgame-oracle/target/classes/chess/Square.class
  15. BIN  endgame-oracle/target/classes/chess/SquareContainsNoPiecesException.class
  16. BIN  endgame-oracle/target/classes/chess/SquareHasNoAdjacentSquareException.class
  17. 71  endgame-oracle/target/surefire-reports/TEST-chess.ChessPositionTest.xml
  18. 84  endgame-oracle/target/surefire-reports/TEST-chess.SquareTest.xml
  19. 10  endgame-oracle/target/surefire-reports/TEST-tablebases.TablebaseTest.xml
  20. 4  endgame-oracle/target/surefire-reports/chess.ChessPositionTest.txt
  21. 4  endgame-oracle/target/surefire-reports/chess.SquareTest.txt
  22. 2  endgame-oracle/target/surefire-reports/tablebases.TablebaseTest.txt
  23. BIN  endgame-oracle/target/test-classes/chess/ChessPositionTest.class
  24. BIN  endgame-oracle/target/test-classes/chess/SquareTest.class
142  endgame-oracle/src/main/java/chess/ChessPosition.java
... ...
@@ -0,0 +1,142 @@
  1
+package chess;
  2
+
  3
+import java.util.ArrayList;
  4
+import java.util.HashSet;
  5
+import java.util.List;
  6
+import java.util.Set;
  7
+
  8
+import com.google.common.collect.BiMap;
  9
+import com.google.common.collect.EnumBiMap;
  10
+
  11
+import tablebases.Tablebase;
  12
+
  13
+/** Representation of chess position: side to move, White and Black 
  14
+ * pieces, and their respective squares. */
  15
+public class ChessPosition {
  16
+    private BiMap<Piece, Square> piecesWithSquares;
  17
+    private SideToMove sideToMove;
  18
+    
  19
+    private ChessPosition(BiMap<Piece, Square> piecesWithSquares,
  20
+	    SideToMove sideToMove) {
  21
+	this.piecesWithSquares = piecesWithSquares;
  22
+	this.sideToMove = sideToMove;
  23
+    }
  24
+    
  25
+    private ChessPosition(Tablebase tablebase,
  26
+	    List<Square> squares, SideToMove sideToMove) {
  27
+	piecesWithSquares = EnumBiMap.create(Piece.class, Square.class);	
  28
+	if (!allSquaresAreDifferent(squares)) {
  29
+	    throw new IllegalArgumentException("Some of the squares provided " +
  30
+	    		"are the same: " + squares.toString());
  31
+	}	
  32
+	List<Piece> pieces = tablebase.getAllPieces();
  33
+	if (pieces.size() > squares.size()) {
  34
+	    throw new IllegalArgumentException("Pieces from " +
  35
+	    		"tablebase " + tablebase + " were not provided " +
  36
+	    		"enough of corresponding squares");	
  37
+	}
  38
+	for (int i = 0; i < pieces.size(); i++) {
  39
+	    piecesWithSquares.put(pieces.get(i), squares.get(i));
  40
+	}
  41
+	this.sideToMove = sideToMove;
  42
+    }
  43
+    
  44
+    private static boolean allSquaresAreDifferent(List<Square> squareList) {
  45
+   	Set<Square> squareSet = new HashSet<>(squareList);
  46
+   	return squareList.size() == squareSet.size();       
  47
+    }
  48
+    
  49
+    public static ChessPosition createFromPiecesToSquaresMap(BiMap<Piece, 
  50
+	    Square> piecesWithSquares, SideToMove sideToMove) {
  51
+	return new ChessPosition(piecesWithSquares, sideToMove);
  52
+    }   
  53
+
  54
+    public static ChessPosition createFromTablebase(Tablebase tablebase,
  55
+	    List<Square> squares, SideToMove sideToMove) {
  56
+	return new ChessPosition(tablebase, squares, sideToMove);
  57
+    }
  58
+    
  59
+    public BiMap<Piece, Square> getPiecesWithSquares() {
  60
+        return piecesWithSquares;
  61
+    }
  62
+
  63
+    public void setPiecesWithSquares(EnumBiMap<Piece, Square> piecesWithSquares) {
  64
+        this.piecesWithSquares = piecesWithSquares;
  65
+    }
  66
+
  67
+    public SideToMove getSideToMove() {
  68
+        return sideToMove;
  69
+    }
  70
+
  71
+    public void setSideToMove(SideToMove sideToMove) {
  72
+        this.sideToMove = sideToMove;
  73
+    }
  74
+
  75
+    @Override
  76
+    public int hashCode() {
  77
+	final int prime = 31;
  78
+	int result = 1;
  79
+	result = prime
  80
+		* result
  81
+		+ ((piecesWithSquares == null) ? 0 : piecesWithSquares
  82
+			.hashCode());
  83
+	result = prime * result
  84
+		+ ((sideToMove == null) ? 0 : sideToMove.hashCode());
  85
+	return result;
  86
+    }
  87
+
  88
+    @Override
  89
+    public boolean equals(Object obj) {
  90
+	if (this == obj)
  91
+	    return true;
  92
+	if (obj == null)
  93
+	    return false;
  94
+	if (getClass() != obj.getClass())
  95
+	    return false;
  96
+	ChessPosition other = (ChessPosition) obj;
  97
+	if (piecesWithSquares == null) {
  98
+	    if (other.piecesWithSquares != null)
  99
+		return false;
  100
+	} else if (!piecesWithSquares.equals(other.piecesWithSquares))
  101
+	    return false;
  102
+	if (sideToMove != other.sideToMove)
  103
+	    return false;
  104
+	return true;
  105
+    }
  106
+
  107
+    public List<Piece> getWhitePieces() {
  108
+	List<Piece> whitePieces = new ArrayList<>();
  109
+	for (Piece p : piecesWithSquares.keySet()) {
  110
+	    if (p == Piece.BLACK_KING)
  111
+		break;	    
  112
+	    whitePieces.add(p);
  113
+	}
  114
+	return whitePieces;
  115
+    }
  116
+
  117
+    public List<Piece> getBlackPieces() {
  118
+	List<Piece> blackPieces = new ArrayList<>();
  119
+	for (Piece p : piecesWithSquares.keySet()) {
  120
+	    if (p.getPieceColour() == PieceColour.BLACK)
  121
+		blackPieces.add(p);
  122
+	}
  123
+	return blackPieces;
  124
+    }
  125
+
  126
+    public List<Square> getWhiteSquares() {
  127
+	List<Square> whiteSquares = new ArrayList<>();
  128
+	for (Piece p : getWhitePieces()) {
  129
+	    whiteSquares.add(piecesWithSquares.get(p));
  130
+	}
  131
+	return whiteSquares;
  132
+    }
  133
+
  134
+    public List<Square> getBlackSquares() {
  135
+	List<Square> blackSquares = new ArrayList<>();
  136
+	for (Piece p : getBlackPieces()) {
  137
+	    blackSquares.add(piecesWithSquares.get(p));
  138
+	}
  139
+	return blackSquares;
  140
+    }    
  141
+    
  142
+}
37  endgame-oracle/src/main/java/chess/ChessPositionEvaluation.java
... ...
@@ -0,0 +1,37 @@
  1
+package chess;
  2
+
  3
+/** Game-theoretical value of position obtained from tablebase. */
  4
+public enum ChessPositionEvaluation {
  5
+    
  6
+    DRAW, WHITE_WINS, BLACK_WINS, ILLEGAL, NOT_EVALUATED;
  7
+    
  8
+    
  9
+    /** Simple data structure representing the evaluation of 
  10
+     * some chess position, which include the additional data member - 
  11
+     * distance-to-mate. */
  12
+    public static class ChessPositionEvaluationWithDTM {
  13
+	private ChessPositionEvaluation chessPositionEvaluation;
  14
+	/** A non-negative number of moves to mate in a position, theoretically won 
  15
+	 * by White or Black. */
  16
+	private int distanceToMate;
  17
+	
  18
+	public ChessPositionEvaluation getChessPositionEvaluation() {
  19
+	    return chessPositionEvaluation;
  20
+	}
  21
+	
  22
+	public void setChessPositionEvaluation(
  23
+		ChessPositionEvaluation chessPositionEvaluation) {
  24
+	    this.chessPositionEvaluation = chessPositionEvaluation;
  25
+	}
  26
+	
  27
+	public int getDistanceToMate() {
  28
+	    return distanceToMate;
  29
+	}
  30
+	
  31
+	public void setDistanceToMate(int distanceToMate) {
  32
+	    this.distanceToMate = distanceToMate;
  33
+	}
  34
+	
  35
+    }	
  36
+    
  37
+}
7  endgame-oracle/src/main/java/chess/SideToMove.java
... ...
@@ -0,0 +1,7 @@
  1
+package chess;
  2
+
  3
+/** Side-to-move in a chess position. 
  4
+ * <dt><b>Precondition:</b><dd>Must correspond with the enum PieceColour. */
  5
+public enum SideToMove {
  6
+    WHITE, BLACK
  7
+}
221  endgame-oracle/src/main/java/chess/Square.java
... ...
@@ -0,0 +1,221 @@
  1
+package chess;
  2
+
  3
+import java.util.ArrayList;
  4
+import java.util.EnumSet;
  5
+import java.util.HashSet;
  6
+import java.util.List;
  7
+import java.util.Set;
  8
+
  9
+/** Chessboard square that can be empty or occupied by one of the chess 
  10
+ * pieces. There are 64 squares on the chessboard. Each square can be 
  11
+ * uniquely identified by its file (a, b, c, d, e, f, g, or h, corresponding 
  12
+ * to integers from 1 to 8) and rank (1, 2, ..., 8). */
  13
+public enum Square {
  14
+    
  15
+    A8(18), B8(28), C8(38), D8(48), E8(58), F8(68), G8(78), H8(88), 
  16
+    A7(17), B7(27), C7(37), D7(47), E7(57), F7(67), G7(77), H7(87), 
  17
+    A6(16), B6(26), C6(36), D6(46), E6(56), F6(66), G6(76), H6(86), 
  18
+    A5(15), B5(25), C5(35), D5(45), E5(55), F5(65), G5(75), H5(85), 
  19
+    A4(14), B4(24), C4(34), D4(44), E4(54), F4(64), G4(74), H4(84), 
  20
+    A3(13), B3(23), C3(33), D3(43), E3(53), F3(63), G3(73), H3(83), 
  21
+    A2(12), B2(22), C2(32), D2(42), E2(52), F2(62), G2(72), H2(82), 
  22
+    A1(11), B1(21), C1(31), D1(41), E1(51), F1(61), G1(71), H1(81);    
  23
+
  24
+    /** An integer identifying this square. */
  25
+    private final int squareID;    
  26
+
  27
+    private Square(int squareID) {
  28
+	this.squareID = squareID;
  29
+    }
  30
+
  31
+    /** @return ID of the square - integer from 11 to 88, where the 
  32
+     * first digit corresponds to the file of the square, and the second 
  33
+     * digit - to the rank of the square  */
  34
+    public int getSquareID() {
  35
+	return squareID;
  36
+    }    
  37
+
  38
+    /** @return file of this square as an integer (1 to 8, corresponding 
  39
+     * to files a to h) */
  40
+    public int getFile() {
  41
+	return squareID / 10;
  42
+    }
  43
+
  44
+    /** @return rank of this square as an integer (1 to 8) */
  45
+    public int getRank() {
  46
+	return squareID % 10;
  47
+    }
  48
+    
  49
+    /** Converts file and rank specified as integers between 
  50
+     * 1 and 8 to the corresponding square. */
  51
+    protected static Square getSquareFromFileAndRank(int file, int rank) {
  52
+	if (file < 1 || file > 8)
  53
+	    throw new IllegalArgumentException("Invalid file value: " + file);
  54
+	if (rank < 1 || rank > 8)
  55
+	    throw new IllegalArgumentException("Invalid rank value: " + rank);
  56
+	int squareID = file*10 + rank;
  57
+	return getSquareFromID(squareID);
  58
+    }
  59
+
  60
+    /** Converts squareID (integer from 11 to 88) to the corresponding Square. */
  61
+    public static Square getSquareFromID(int squareID) {
  62
+	for (Square sq : EnumSet.allOf(Square.class)) {
  63
+	    if (sq.getSquareID() == squareID)
  64
+		return sq;
  65
+	}
  66
+	throw new IllegalArgumentException("Square with value " + squareID + " does not exist!");
  67
+    }
  68
+
  69
+    /** Direction from this Square to the adjacent Square - East, Southeast, etc. */
  70
+    public enum Direction {	
  71
+	EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST, NORTH, NORTHEAST
  72
+    }
  73
+    
  74
+    /** Checks if this square has an adjacent square to the specified direction. 
  75
+     * @see #getAdjacentSquare(Direction) */
  76
+    public boolean hasAdjacentSquareTo(Direction direction) {
  77
+	switch(direction) {
  78
+	case EAST: 
  79
+	    return this.getFile() == 8 ? false : true; 
  80
+	case SOUTHEAST: 
  81
+	    return this.getFile() == 8 || this.getRank() == 1 ? false : true;
  82
+	case SOUTH: 
  83
+	    return this.getRank() == 1 ? false : true;
  84
+	case SOUTHWEST:
  85
+	    return this.getFile() == 1 || this.getRank() == 1 ? false : true;
  86
+	case WEST: 
  87
+	    return this.getFile() == 1 ? false : true;
  88
+	case NORTHWEST: 
  89
+	    return this.getFile() == 1 || this.getRank() == 8 ? false : true;
  90
+	case NORTH: 
  91
+	    return this.getRank() == 8 ? false : true;
  92
+	case NORTHEAST: 
  93
+	    return this.getFile() == 8 || this.getRank() == 8 ? false : true;
  94
+	default: 
  95
+	    throw new AssertionError("Unknown direction: " + direction);
  96
+	}	    
  97
+    } 
  98
+    
  99
+    /** @param direction - east (to the right of this square), southeast (to the 
  100
+     * right and down), etc.
  101
+     * <dt><b>Precondition:</b><dd>Must have an adjacent square
  102
+     * @return adjacent square to the specified direction
  103
+     * @see #hasAdjacentSquareTo(Direction direction) */
  104
+    public Square getAdjacentSquare(Direction direction) {	
  105
+	switch(direction) {
  106
+	case EAST: 
  107
+	    return getSquareFromFileAndRank(this.getFile() + 1, this.getRank());
  108
+	case SOUTHEAST: 
  109
+	    return getSquareFromFileAndRank(this.getFile() + 1, this.getRank() - 1);
  110
+	case SOUTH: 
  111
+	    return getSquareFromFileAndRank(this.getFile(), this.getRank() - 1);
  112
+	case SOUTHWEST:
  113
+	    return getSquareFromFileAndRank(this.getFile() - 1, this.getRank() - 1);
  114
+	case WEST: 
  115
+	    return getSquareFromFileAndRank(this.getFile() - 1, this.getRank());
  116
+	case NORTHWEST: 
  117
+	    return getSquareFromFileAndRank(this.getFile() - 1, this.getRank() + 1);
  118
+	case NORTH: 
  119
+	    return getSquareFromFileAndRank(this.getFile(), this.getRank() + 1);
  120
+	case NORTHEAST: 
  121
+	    return getSquareFromFileAndRank(this.getFile() + 1, this.getRank() + 1);
  122
+	default: 
  123
+	    throw new AssertionError("Unknown direction: " + direction);
  124
+	}	    
  125
+    } 
  126
+    
  127
+    /** Assembles a list of consequtive squares from the starting
  128
+     * square given a chess position and direction. Range ends with 
  129
+     * the edge of the board, or with the square containing another 
  130
+     * piece (that square is included in the range). This method is 
  131
+     * applicable to long-range pieces. */
  132
+    public List<Square> rangeOfSquares(ChessPosition 
  133
+	    chessPosition, Direction direction) {
  134
+	List<Square> squares = new ArrayList<>();
  135
+	Square nextSq = this;
  136
+	while (nextSq.hasAdjacentSquareTo(direction)) {
  137
+	    nextSq = nextSq.getAdjacentSquare(direction);
  138
+	    squares.add(nextSq);
  139
+	    if (nextSq.containsPiece(chessPosition))
  140
+		return squares;	    
  141
+	}	    
  142
+	return squares;
  143
+    }
  144
+    
  145
+    /** Checks if this square does contain some chess piece, i.e. if it is not empty. */
  146
+    public boolean containsPiece(ChessPosition chessPosition) {
  147
+	return chessPosition.getPiecesWithSquares().values().contains(this);
  148
+    }
  149
+    
  150
+    /** @return the last square of the range
  151
+     * <dt><b>Precondition:</b><dd>the range cannot be empty 
  152
+     * @throws SquareHasNoAdjacentSquareException */
  153
+    public Square getSquareAtTheEndOfRange(ChessPosition 
  154
+	    chessPosition, Direction direction) 
  155
+		    throws SquareHasNoAdjacentSquareException {
  156
+	if (!this.hasAdjacentSquareTo(direction))
  157
+	    throw new SquareHasNoAdjacentSquareException("Square " + this + " has " +
  158
+	    		"no adjacent square to the " + direction + " in the chess " +
  159
+	    		"position:\n\n" + chessPosition + "\n\n");
  160
+	List<Square> range = this.rangeOfSquares(chessPosition, direction);	
  161
+	return range.get(range.size() - 1);
  162
+    }
  163
+    
  164
+    /** @return the first piece to the specified direction.
  165
+     * <dt><b>Precondition:</b><dd>the range to the specified
  166
+     * direction must contain a square with some piece on it. 
  167
+     * @throws SquareHasNoAdjacentSquareException 
  168
+     * @throws SquareContainsNoPiecesException */
  169
+    public Piece getPieceAtTheEndOfRange(ChessPosition chessPosition, Direction direction) 
  170
+	    throws SquareHasNoAdjacentSquareException, SquareContainsNoPiecesException {
  171
+	Square sq = this.getSquareAtTheEndOfRange(chessPosition, direction);
  172
+	Piece pc = sq.getPiece(chessPosition);
  173
+	return pc;
  174
+    }    
  175
+
  176
+    /** @return the piece that this square contains 
  177
+     * @throws SquareContainsNoPiecesException */
  178
+    public Piece getPiece(ChessPosition chessPosition) throws SquareContainsNoPiecesException {  
  179
+	if (!this.containsPiece(chessPosition)) {
  180
+	    throw new SquareContainsNoPiecesException("Square " + this + " contains " +
  181
+	    		"no piece in the chess " +
  182
+	    		"position:\n\n" + chessPosition + "\n\n");
  183
+	}
  184
+	return chessPosition.getPiecesWithSquares().inverse().get(this);
  185
+    }
  186
+    
  187
+    /** Checks if this square is adjacent to the given square */
  188
+    public boolean isAdjacent(Square sq) {
  189
+	return     Math.abs(this.getFile() - sq.getFile()) < 2
  190
+		&& Math.abs(this.getRank() - sq.getRank()) < 2;	
  191
+    }
  192
+    
  193
+    /** Assembles the rectangle zone of squares between the specified  squares.
  194
+     * @param begin a corner of the rectangle 
  195
+     * @param end a corner of the rectangle opposite (both vertically and horizontally) to begin  */
  196
+    public static Set<Square> getRectangleZone(Square begin, Square end) {
  197
+	if (begin.getSquareID() > end.getSquareID())
  198
+	    return getRectangleZone(end, begin); 
  199
+	/* Now rank of begin <= than rank of end */
  200
+	Set<Square> squareZone = new HashSet<>();
  201
+	int beginFile = begin.getFile();
  202
+	int beginRank = begin.getRank();
  203
+	int endFile = end.getFile();
  204
+	int endRank = end.getRank();
  205
+	if (beginFile <= endFile) {
  206
+	    for (int file = beginFile; file <= endFile; file++) {
  207
+		for (int rank = beginRank; rank <= endRank; rank++) {
  208
+		    squareZone.add(Square.getSquareFromFileAndRank(file, rank));
  209
+		}
  210
+	    }
  211
+	} else {
  212
+	    for (int file = endFile; file <= beginFile; file++) {
  213
+		for (int rank = beginRank; rank <= endRank; rank++) {
  214
+		    squareZone.add(Square.getSquareFromFileAndRank(file, rank));
  215
+		}
  216
+	    }
  217
+	}
  218
+	return squareZone;	
  219
+    }	
  220
+    
  221
+} 
12  endgame-oracle/src/main/java/chess/SquareContainsNoPiecesException.java
... ...
@@ -0,0 +1,12 @@
  1
+package chess;
  2
+
  3
+/** An exception that occurs when the square is expected to 
  4
+ * contain some piece, but does not. */
  5
+public class SquareContainsNoPiecesException extends Exception {
  6
+
  7
+    private static final long serialVersionUID = -5331133672234425506L;
  8
+
  9
+    public SquareContainsNoPiecesException(String message) {
  10
+        super("\n" + message);
  11
+    }
  12
+}
13  endgame-oracle/src/main/java/chess/SquareHasNoAdjacentSquareException.java
... ...
@@ -0,0 +1,13 @@
  1
+package chess;
  2
+
  3
+/** Represents an exception occuring when a square is expected 
  4
+ * to have an adjacent square, but does not have. */
  5
+public class SquareHasNoAdjacentSquareException extends Exception {
  6
+
  7
+    private static final long serialVersionUID = -3604688674460679824L;
  8
+
  9
+    public SquareHasNoAdjacentSquareException(String message) {
  10
+        super("\n" + message);
  11
+    }
  12
+
  13
+}
174  endgame-oracle/src/test/java/chess/ChessPositionTest.java
... ...
@@ -0,0 +1,174 @@
  1
+package chess;
  2
+
  3
+import static org.junit.Assert.*;
  4
+import static org.mockito.Mockito.*;
  5
+import java.util.ArrayList;
  6
+import java.util.List;
  7
+import java.util.Map;
  8
+import org.junit.Before;
  9
+import org.junit.Test;
  10
+
  11
+import com.google.common.collect.BiMap;
  12
+import com.google.common.collect.EnumBiMap;
  13
+
  14
+import tablebases.Tablebase;
  15
+
  16
+public class ChessPositionTest {
  17
+    private ChessPosition mockedChessPosition;
  18
+    private ChessPosition chessPositionFromKRPKR, chessPositionFromKBNKPPP;    
  19
+
  20
+    @Before
  21
+    public void setUp() throws Exception {
  22
+	mockedChessPosition = mock(ChessPosition.class);
  23
+	
  24
+	List<Square> squaresKRPKR = new ArrayList<>();
  25
+	squaresKRPKR.add(Square.E5);
  26
+	squaresKRPKR.add(Square.E3);
  27
+	squaresKRPKR.add(Square.D5);
  28
+	squaresKRPKR.add(Square.H8);
  29
+	squaresKRPKR.add(Square.D1);
  30
+	chessPositionFromKRPKR = 
  31
+		ChessPosition.createFromTablebase(
  32
+		Tablebase.KRPKR, squaresKRPKR, SideToMove.WHITE);
  33
+	
  34
+	BiMap<Piece, Square> piecesWithSquaresKBNKPPP = 
  35
+		EnumBiMap.create(Piece.class, Square.class);	
  36
+	piecesWithSquaresKBNKPPP.put(Piece.WHITE_KING, Square.A3);
  37
+	piecesWithSquaresKBNKPPP.put(Piece.WHITE_BISHOP, Square.E5);
  38
+	piecesWithSquaresKBNKPPP.put(Piece.WHITE_KNIGHT, Square.E3);
  39
+	piecesWithSquaresKBNKPPP.put(Piece.BLACK_KING, Square.G2);
  40
+	piecesWithSquaresKBNKPPP.put(Piece.BLACK_PAWN, Square.H4);
  41
+	piecesWithSquaresKBNKPPP.put(Piece.BLACK_PAWN_2, Square.H3);
  42
+	piecesWithSquaresKBNKPPP.put(Piece.BLACK_PAWN_3, Square.G6);
  43
+	
  44
+	chessPositionFromKBNKPPP = 
  45
+		ChessPosition.createFromPiecesToSquaresMap(
  46
+			piecesWithSquaresKBNKPPP, SideToMove.BLACK);
  47
+		
  48
+    }
  49
+
  50
+    @Test
  51
+    public void getPiecesAndSquaresMapTest1() {	
  52
+	mockedChessPosition.getPiecesWithSquares();
  53
+	verify(mockedChessPosition).getPiecesWithSquares();
  54
+    }
  55
+    
  56
+    @Test(expected = IllegalArgumentException.class)
  57
+    public void getSquaresToPiecesMapThrowsIllegalArgumentExceptionTest1() {
  58
+	List<Square> squares2 = new ArrayList<>();
  59
+	squares2.add(Square.E5);
  60
+	squares2.add(Square.E5);
  61
+	squares2.add(Square.D5);
  62
+	squares2.add(Square.H8);
  63
+	squares2.add(Square.D1);
  64
+	ChessPosition chessPositionFromTbDuplicateSquares = 
  65
+		ChessPosition.createFromTablebase(
  66
+		Tablebase.KRPKR, squares2, SideToMove.WHITE);
  67
+	Map<Piece,Square> actualMap = chessPositionFromTbDuplicateSquares.getPiecesWithSquares();
  68
+	
  69
+	assertEquals(5, actualMap.keySet().size());
  70
+    }
  71
+    
  72
+    @Test(expected = IllegalArgumentException.class)
  73
+    public void getPiecesToSquaresThrowsIllegalArgumentExceptionTest2() {
  74
+	List<Square> squares3 = new ArrayList<>();
  75
+	squares3.add(Square.E3);
  76
+	squares3.add(Square.D5);
  77
+	squares3.add(Square.H8);
  78
+	squares3.add(Square.D1);
  79
+	ChessPosition chessPositionFromTbTooFewSquares = 
  80
+		ChessPosition.createFromTablebase(
  81
+			Tablebase.KRPKR, squares3, SideToMove.WHITE);
  82
+	Map<Piece,Square> actualMap = 
  83
+		chessPositionFromTbTooFewSquares.getPiecesWithSquares();
  84
+	
  85
+	assertEquals(4, actualMap.keySet().size());
  86
+    }
  87
+    
  88
+    @Test
  89
+    public void getWhitePiecesTest() {
  90
+	List<Piece> expectedWhitePiecesKRPKR = new ArrayList<>();
  91
+	expectedWhitePiecesKRPKR.add(Piece.WHITE_KING);
  92
+	expectedWhitePiecesKRPKR.add(Piece.WHITE_ROOK);
  93
+	expectedWhitePiecesKRPKR.add(Piece.WHITE_PAWN);
  94
+	
  95
+	List<Piece> actualWhitePiecesKRPKR = chessPositionFromKRPKR.getWhitePieces();
  96
+	
  97
+	assertEquals(expectedWhitePiecesKRPKR, actualWhitePiecesKRPKR);
  98
+	
  99
+	List<Piece> expectedWhitePiecesKBNKPPP = new ArrayList<>();
  100
+	expectedWhitePiecesKBNKPPP.add(Piece.WHITE_KING);
  101
+	expectedWhitePiecesKBNKPPP.add(Piece.WHITE_BISHOP);
  102
+	expectedWhitePiecesKBNKPPP.add(Piece.WHITE_KNIGHT);
  103
+	
  104
+	List<Piece> actualWhitePiecesKBNKPPP = chessPositionFromKBNKPPP.getWhitePieces();
  105
+	
  106
+	assertEquals(expectedWhitePiecesKBNKPPP, actualWhitePiecesKBNKPPP);
  107
+    }
  108
+    
  109
+    @Test
  110
+    public void getBlackPiecesTest() {
  111
+	List<Piece> expectedBlackPiecesKRPKR = new ArrayList<>();
  112
+	expectedBlackPiecesKRPKR.add(Piece.BLACK_KING);
  113
+	expectedBlackPiecesKRPKR.add(Piece.BLACK_ROOK);
  114
+	
  115
+	List<Piece> actualBlackPiecesKRPKR = chessPositionFromKRPKR.getBlackPieces();
  116
+	
  117
+	assertEquals(expectedBlackPiecesKRPKR, actualBlackPiecesKRPKR);
  118
+	
  119
+	List<Piece> expectedBlackPiecesKBNKPPP = new ArrayList<>();
  120
+	expectedBlackPiecesKBNKPPP.add(Piece.BLACK_KING);
  121
+	expectedBlackPiecesKBNKPPP.add(Piece.BLACK_PAWN);
  122
+	expectedBlackPiecesKBNKPPP.add(Piece.BLACK_PAWN_2);
  123
+	expectedBlackPiecesKBNKPPP.add(Piece.BLACK_PAWN_3);
  124
+	
  125
+	List<Piece> actualBlackPiecesKBNKPPP = chessPositionFromKBNKPPP.getBlackPieces();
  126
+	
  127
+	assertEquals(expectedBlackPiecesKBNKPPP, actualBlackPiecesKBNKPPP);
  128
+    }
  129
+    
  130
+    @Test
  131
+    public void getWhiteSquaresTest() {
  132
+	List<Square> expectedWhiteSquaresKRPKR = new ArrayList<>();
  133
+	expectedWhiteSquaresKRPKR.add(Square.E5);
  134
+	expectedWhiteSquaresKRPKR.add(Square.E3);
  135
+	expectedWhiteSquaresKRPKR.add(Square.D5);
  136
+
  137
+	List<Square> actualWhiteSquaresKRPKR = chessPositionFromKRPKR.getWhiteSquares();
  138
+	
  139
+	assertEquals(expectedWhiteSquaresKRPKR, actualWhiteSquaresKRPKR);
  140
+	
  141
+	List<Square> expectedWhiteSquaresKBNKPPP = new ArrayList<>();
  142
+	expectedWhiteSquaresKBNKPPP.add(Square.A3);
  143
+	expectedWhiteSquaresKBNKPPP.add(Square.E5);
  144
+	expectedWhiteSquaresKBNKPPP.add(Square.E3);
  145
+	
  146
+	List<Square> actualWhiteSquaresKBNKPPP = chessPositionFromKBNKPPP.getWhiteSquares();
  147
+	
  148
+	assertEquals(expectedWhiteSquaresKBNKPPP, actualWhiteSquaresKBNKPPP);
  149
+    }
  150
+    
  151
+    @Test
  152
+    public void getBlackSquaresTest() {
  153
+	List<Square> expectedBlackSquaresKRPKR = new ArrayList<>();
  154
+	expectedBlackSquaresKRPKR.add(Square.H8);
  155
+	expectedBlackSquaresKRPKR.add(Square.D1);
  156
+	
  157
+	List<Square> actualBlackSquaresKRPKR = chessPositionFromKRPKR.getBlackSquares();
  158
+	
  159
+	assertEquals(expectedBlackSquaresKRPKR, actualBlackSquaresKRPKR);
  160
+	
  161
+	List<Square> expectedBlackSquaresKBNKPPP = new ArrayList<>();
  162
+	expectedBlackSquaresKBNKPPP.add(Square.G2);
  163
+	expectedBlackSquaresKBNKPPP.add(Square.H4);
  164
+	expectedBlackSquaresKBNKPPP.add(Square.H3);
  165
+	expectedBlackSquaresKBNKPPP.add(Square.G6);
  166
+	
  167
+	List<Square> actualBlackSquaresKBNKPPP = chessPositionFromKBNKPPP.getBlackSquares();
  168
+	
  169
+	assertEquals(expectedBlackSquaresKBNKPPP, actualBlackSquaresKBNKPPP);
  170
+    }
  171
+    
  172
+    
  173
+    
  174
+}
287  endgame-oracle/src/test/java/chess/SquareTest.java
... ...
@@ -0,0 +1,287 @@
  1
+package chess;
  2
+
  3
+import static org.junit.Assert.*;
  4
+
  5
+import java.util.ArrayList;
  6
+import java.util.EnumSet;
  7
+import java.util.HashSet;
  8
+import java.util.List;
  9
+import java.util.Set;
  10
+
  11
+import org.junit.Before;
  12
+import org.junit.Test;
  13
+
  14
+import com.google.common.collect.BiMap;
  15
+import com.google.common.collect.EnumBiMap;
  16
+
  17
+import chess.Square.Direction;
  18
+
  19
+public class SquareTest {
  20
+
  21
+    private Square squareA1, squareE3, squareH8;
  22
+    private Square[] testedSquares;
  23
+    private int testedSquaresCount;
  24
+    private Set<Direction> allDirectionsClockwiseFromEastToNorthEast;
  25
+    private ChessPosition chessPosition1;
  26
+    
  27
+    @Before
  28
+    public void setUp() throws Exception {
  29
+	squareA1 = Square.A1;
  30
+	squareE3 = Square.E3;
  31
+	squareH8 = Square.H8;
  32
+	testedSquares = new Square[] { squareA1, squareE3, squareH8 };
  33
+	testedSquaresCount = testedSquares.length;
  34
+	allDirectionsClockwiseFromEastToNorthEast = EnumSet.allOf(Direction.class);
  35
+	
  36
+	BiMap<Piece, Square> map1 = EnumBiMap.create(Piece.class, Square.class);
  37
+	map1.put(Piece.WHITE_KING, Square.E5);
  38
+	map1.put(Piece.WHITE_PAWN, Square.D5);
  39
+	map1.put(Piece.BLACK_KING, Square.H8);
  40
+	map1.put(Piece.BLACK_ROOK, Square.D1);
  41
+	chessPosition1 = ChessPosition
  42
+		.createFromPiecesToSquaresMap(map1, SideToMove.WHITE); 
  43
+    }
  44
+
  45
+    @Test
  46
+    public void getSquareIDTest() {
  47
+	int[] expectedIDs = new int[] { 11, 53, 88 };
  48
+	int[] actualIDs = new int[testedSquaresCount];
  49
+	for (int i = 0; i < testedSquaresCount; i++) {
  50
+	    actualIDs[i] = testedSquares[i].getSquareID();
  51
+	}
  52
+	
  53
+	assertArrayEquals(expectedIDs, actualIDs);
  54
+    }
  55
+    
  56
+    @Test
  57
+    public void getSquareFileTest() {
  58
+	int[] expectedFiles = new int[] { 1, 5, 8 };
  59
+	int[] actualFiles = new int[testedSquaresCount];
  60
+	for (int i = 0; i < testedSquaresCount; i++) {
  61
+	    actualFiles[i] = testedSquares[i].getFile();
  62
+	}
  63
+	
  64
+	assertArrayEquals(expectedFiles, actualFiles);
  65
+    }
  66
+    
  67
+    @Test
  68
+    public void getSquareRankTest() {
  69
+	int[] expectedRanks = new int[] { 1, 3, 8 };
  70
+	int[] actualRanks = new int[testedSquaresCount];
  71
+	for (int i = 0; i < testedSquaresCount; i++) {
  72
+	    actualRanks[i] = testedSquares[i].getRank();
  73
+	}
  74
+	
  75
+	assertArrayEquals(expectedRanks, actualRanks);
  76
+    }
  77
+    
  78
+    @Test
  79
+    public void getSquareFromFileAndRankTest() {
  80
+	Square[] expectedSquares = testedSquares;
  81
+	Square[] actualSquares = new Square[] {
  82
+	    Square.getSquareFromFileAndRank(1, 1),
  83
+	    Square.getSquareFromFileAndRank(5, 3),
  84
+	    Square.getSquareFromFileAndRank(8, 8) 
  85
+	};
  86
+	
  87
+	assertArrayEquals(expectedSquares, actualSquares);
  88
+    }
  89
+    
  90
+    @Test(expected = IllegalArgumentException.class)
  91
+    public void getSquareFromFileAndRankThrowsIllegalArgumentExceptionTest() {
  92
+	Square.getSquareFromFileAndRank(0, 1);	    
  93
+    }
  94
+
  95
+    @Test
  96
+    public void getSquareFromID() {
  97
+	Square[] expectedSquares = testedSquares;
  98
+	Square[] actualSquares = new Square[] {
  99
+	    Square.getSquareFromID(11),
  100
+	    Square.getSquareFromID(53),
  101
+	    Square.getSquareFromID(88) 	    
  102
+	};
  103
+	
  104
+	assertArrayEquals(expectedSquares, actualSquares);
  105
+    }
  106
+    
  107
+    @Test(expected = IllegalArgumentException.class)
  108
+    public void getSquareFromIDThrowsIllegalArgumentExceptionTest() {
  109
+	Square.getSquareFromID(0);	    
  110
+    }
  111
+    
  112
+    @Test
  113
+    public void hasAdjacentSquareToTest() {
  114
+	for (Direction dir : allDirectionsClockwiseFromEastToNorthEast) {
  115
+	    assertTrue(squareE3.hasAdjacentSquareTo(dir));	    
  116
+	}
  117
+	
  118
+	EnumSet<Direction> directionsFromSquareA1ThatAreOutsideChessBoard = 
  119
+		EnumSet.range(Direction.SOUTHEAST, Direction.NORTHWEST);
  120
+	for (Direction dir : directionsFromSquareA1ThatAreOutsideChessBoard) {
  121
+	    assertFalse(squareA1.hasAdjacentSquareTo(dir));
  122
+	}
  123
+	for (Direction dir : EnumSet.complementOf(directionsFromSquareA1ThatAreOutsideChessBoard)) {
  124
+	    assertTrue(squareA1.hasAdjacentSquareTo(dir));
  125
+	}
  126
+	
  127
+	EnumSet<Direction> directionsFromSquareH8ThatAreInsideChessBoard = 
  128
+		EnumSet.of(Direction.SOUTH, Direction.SOUTHWEST, Direction.WEST);
  129
+	for (Direction dir : directionsFromSquareH8ThatAreInsideChessBoard) {
  130
+	    assertTrue(squareH8.hasAdjacentSquareTo(dir));
  131
+	}
  132
+	for (Direction dir : EnumSet.complementOf(directionsFromSquareH8ThatAreInsideChessBoard)) {
  133
+	    assertFalse(squareH8.hasAdjacentSquareTo(dir));
  134
+	}
  135
+    }
  136
+    
  137
+    @Test 
  138
+    public void getAdjacentSquareTest() {
  139
+	Square[] expectedSquaresToTheEast = new Square[] { Square.B1, Square.F3 };
  140
+	Square[] actualSquaresToTheEast = new Square[] {
  141
+		squareA1.getAdjacentSquare(Direction.EAST), 
  142
+		squareE3.getAdjacentSquare(Direction.EAST) }; 
  143
+	assertArrayEquals(expectedSquaresToTheEast, actualSquaresToTheEast);
  144
+    }
  145
+    
  146
+    @Test 
  147
+    public void containsPieceTest() {
  148
+	assertFalse(squareA1.containsPiece(chessPosition1));
  149
+	assertFalse(squareE3.containsPiece(chessPosition1));
  150
+	assertTrue(squareH8.containsPiece(chessPosition1));
  151
+    }
  152
+    
  153
+    @Test 
  154
+    public void rangeOfSquaresEndsWithPieceTest() {	
  155
+	List<Square> expectedRange = new ArrayList<>();
  156
+	expectedRange.add(Square.B1);
  157
+	expectedRange.add(Square.C1);
  158
+	expectedRange.add(Square.D1);
  159
+	
  160
+	List<Square> actualRange = squareA1.rangeOfSquares(chessPosition1, Direction.EAST);
  161
+	
  162
+	assertEquals(expectedRange, actualRange);
  163
+    }
  164
+    
  165
+    @Test 
  166
+    public void rangeOfSquaresEndsChessboardEdgeTest() {	
  167
+	List<Square> expectedRange = new ArrayList<>();
  168
+	expectedRange.add(Square.F2);
  169
+	expectedRange.add(Square.G1);
  170
+	
  171
+	List<Square> actualRange = squareE3.rangeOfSquares(
  172
+		chessPosition1, Direction.SOUTHEAST);
  173
+	
  174
+	assertEquals(expectedRange, actualRange);
  175
+    }
  176
+    
  177
+    @Test 
  178
+    public void rangeOfSquaresIsEmptyTest() {	
  179
+	List<Square> expectedRange = new ArrayList<>();
  180
+	
  181
+	List<Square> actualRange = squareH8.rangeOfSquares(chessPosition1, Direction.NORTHWEST);
  182
+	actualRange.addAll(squareH8.rangeOfSquares(chessPosition1, Direction.NORTH));
  183
+	actualRange.addAll(squareH8.rangeOfSquares(chessPosition1, Direction.NORTHEAST));
  184
+	actualRange.addAll(squareH8.rangeOfSquares(chessPosition1, Direction.EAST));
  185
+	actualRange.addAll(squareH8.rangeOfSquares(chessPosition1, Direction.SOUTHEAST));
  186
+
  187
+	assertEquals(expectedRange, actualRange);
  188
+    }
  189
+    
  190
+    @Test 
  191
+    public void getSquareAtTheEndOfRangeTest() {
  192
+	Square[] expectedSquares = { Square.E5, Square.H8, Square.B8, Square.A8 };
  193
+	
  194
+	Square sq1 = null, sq2 = null, sq3 = null, sq4 = null;
  195
+	try {
  196
+	    sq1 = squareE3.getSquareAtTheEndOfRange(chessPosition1, Direction.NORTH);
  197
+	    sq2 = Square.E5.getSquareAtTheEndOfRange(chessPosition1, Direction.NORTHEAST);
  198
+	    sq3 = Square.E5.getSquareAtTheEndOfRange(chessPosition1, Direction.NORTHWEST);
  199
+	    sq4 = squareA1.getSquareAtTheEndOfRange(chessPosition1, Direction.NORTH);
  200
+	} catch (SquareHasNoAdjacentSquareException e) {
  201
+	    e.printStackTrace();
  202
+	}
  203
+	Square[] actualSquares = { sq1, sq2, sq3, sq4 };
  204
+	
  205
+	assertArrayEquals(expectedSquares, actualSquares);
  206
+    }
  207
+    
  208
+    @Test(expected = SquareHasNoAdjacentSquareException.class) 
  209
+    public void getSquareAtTheEndOfRangeThrowsSquareHasNoAdjacentSquareExceptionTest() 
  210
+	    throws SquareHasNoAdjacentSquareException {
  211
+	Square sq = null;
  212
+	try {
  213
+	    sq = squareA1.getSquareAtTheEndOfRange(chessPosition1, Direction.SOUTH);
  214
+	} catch (SquareHasNoAdjacentSquareException e) {
  215
+	    assertEquals("\nSquare A1", e.getMessage().substring(0, 10));
  216
+	    throw e;
  217
+	}
  218
+	
  219
+	assertFalse(sq == null);
  220
+    }
  221
+    
  222
+    @Test 
  223
+    public void getPieceTest() {
  224
+	Piece[] expectedPieces = { Piece.WHITE_KING, Piece.BLACK_KING, Piece.BLACK_ROOK };
  225
+	
  226
+	Piece pc1 = null, pc2 = null, pc3 = null;
  227
+	try {
  228
+	    pc1 = Square.E5.getPiece(chessPosition1);
  229
+	    pc2 = Square.H8.getPiece(chessPosition1);
  230
+	    pc3 = Square.D1.getPiece(chessPosition1);
  231
+	} catch (SquareContainsNoPiecesException e) {
  232
+	    e.printStackTrace();
  233
+	}
  234
+	Piece[] actualPieces = { pc1, pc2, pc3 };
  235
+	
  236
+	assertArrayEquals(expectedPieces, actualPieces);	
  237
+    }
  238
+    
  239
+    @Test(expected = SquareContainsNoPiecesException.class) 
  240
+    public void getPieceThrowsSquareContainsNoPiecesExceptionTest() 
  241
+	    throws SquareContainsNoPiecesException {
  242
+	Piece pc = null;
  243
+	try {
  244
+	    pc = squareA1.getPiece(chessPosition1);
  245
+	} catch (SquareContainsNoPiecesException e) {
  246
+	    assertEquals("\nSquare A1", e.getMessage().substring(0, 10));
  247
+	    throw e;
  248
+	}
  249
+	
  250
+	assertFalse(pc == null);
  251
+    }
  252
+    
  253
+    @Test 
  254
+    public void getPieceAtTheEndOfRangeTest() 
  255
+	    throws SquareHasNoAdjacentSquareException, SquareContainsNoPiecesException {
  256
+	Piece[] expectedPieces = { Piece.WHITE_KING, Piece.WHITE_KING, Piece.BLACK_ROOK };
  257
+	
  258
+	Piece pc1 = squareE3.getPieceAtTheEndOfRange(chessPosition1, Direction.NORTH);
  259
+	Piece pc2 = squareA1.getPieceAtTheEndOfRange(chessPosition1, Direction.NORTHEAST);
  260
+	Piece pc3 = squareA1.getPieceAtTheEndOfRange(chessPosition1, Direction.EAST);
  261
+	Piece[] actualPieces = { pc1, pc2, pc3 };
  262
+	
  263
+	assertArrayEquals(expectedPieces, actualPieces);
  264
+    }
  265
+    
  266
+    @Test 
  267
+    public void isAdjacentTest() {
  268
+	assertTrue(squareA1.isAdjacent(Square.A2));
  269
+	assertFalse(squareA1.isAdjacent(squareE3));
  270
+    }
  271
+    
  272
+    @Test 
  273
+    public void getRectangleZoneTest() {
  274
+	Set<Square> expectedSquares = new HashSet<Square>();
  275
+	expectedSquares.add(Square.A1);
  276
+	expectedSquares.add(Square.A2);
  277
+	expectedSquares.add(Square.B1);
  278
+	expectedSquares.add(Square.B2);
  279
+	expectedSquares.add(Square.C1);
  280
+	expectedSquares.add(Square.C2);
  281
+	
  282
+	Set<Square> actualSquares = Square.getRectangleZone(Square.C2, Square.A1);
  283
+	
  284
+	assertEquals(expectedSquares, actualSquares);
  285
+    }
  286
+    
  287
+}
BIN  endgame-oracle/target/classes/chess/ChessPosition.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/ChessPositionEvaluation$ChessPositionEvaluationWithDTM.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/ChessPositionEvaluation.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/SideToMove.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/Square$Direction.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/Square.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/SquareContainsNoPiecesException.class
Binary file not shown
BIN  endgame-oracle/target/classes/chess/SquareHasNoAdjacentSquareException.class
Binary file not shown
71  endgame-oracle/target/surefire-reports/TEST-chess.ChessPositionTest.xml
... ...
@@ -0,0 +1,71 @@
  1
+<?xml version="1.0" encoding="UTF-8" ?>
  2
+<testsuite failures="0" time="0.889" errors="0" skipped="0" tests="7" name="chess.ChessPositionTest">
  3
+  <properties>
  4
+    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
  5
+    <property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.7.0\jre\bin"/>
  6
+    <property name="java.vm.version" value="21.0-b17"/>
  7
+    <property name="user.country.format" value="GB"/>
  8
+    <property name="java.vm.vendor" value="Oracle Corporation"/>
  9
+    <property name="java.vendor.url" value="http://java.oracle.com/"/>
  10
+    <property name="path.separator" value=";"/>
  11
+    <property name="guice.disable.misplaced.annotation.check" value="true"/>
  12
+    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
  13
+    <property name="file.encoding.pkg" value="sun.io"/>
  14
+    <property name="user.script" value=""/>
  15
+    <property name="user.country" value="US"/>
  16
+    <property name="sun.java.launcher" value="SUN_STANDARD"/>
  17
+    <property name="sun.os.patch.level" value="Service Pack 1"/>
  18
+    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
  19
+    <property name="user.dir" value="C:\Users\Kestutis\git\Endgame-Oracle-local-repo\endgame-oracle"/>
  20
+    <property name="java.runtime.version" value="1.7.0-b147"/>
  21
+    <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
  22
+    <property name="java.endorsed.dirs" value="C:\Program Files\Java\jdk1.7.0\jre\lib\endorsed"/>
  23
+    <property name="os.arch" value="amd64"/>
  24
+    <property name="java.io.tmpdir" value="C:\Users\Kestutis\AppData\Local\Temp\"/>
  25
+    <property name="line.separator" value="
  26
+"/>
  27
+    <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
  28
+    <property name="user.variant" value=""/>
  29
+    <property name="os.name" value="Windows 7"/>
  30
+    <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf3775194200877297841.tmp"/>
  31
+    <property name="sun.jnu.encoding" value="Cp1252"/>
  32
+    <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;;."/>
  33
+    <property name="java.specification.name" value="Java Platform API Specification"/>
  34
+    <property name="java.class.version" value="51.0"/>
  35
+    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
  36
+    <property name="os.version" value="6.1"/>
  37
+    <property name="user.home" value="C:\Users\Kestutis"/>
  38
+    <property name="user.timezone" value="Europe/London"/>
  39
+    <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
  40
+    <property name="java.specification.version" value="1.7"/>
  41
+    <property name="file.encoding" value="UTF-8"/>
  42
+    <property name="user.name" value="Kestutis"/>
  43
+    <property name="java.class.path" value="/C:/Users/Kestutis/eclipse/configuration/org.eclipse.osgi/bundles/814/1/.cp/jars/plexus-classworlds-2.4.jar"/>
  44
+    <property name="java.vm.specification.version" value="1.7"/>
  45
+    <property name="sun.arch.data.model" value="64"/>
  46
+    <property name="java.home" value="C:\Program Files\Java\jdk1.7.0\jre"/>
  47
+    <property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher -B test"/>
  48
+    <property name="java.specification.vendor" value="Oracle Corporation"/>
  49
+    <property name="user.language" value="en"/>
  50
+    <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
  51
+    <property name="java.vm.info" value="mixed mode"/>
  52
+    <property name="java.version" value="1.7.0"/>
  53
+    <property name="java.ext.dirs" value="C:\Program Files\Java\jdk1.7.0\jre\lib\ext;C:\Windows\Sun\Java\lib\ext"/>
  54
+    <property name="sun.boot.class.path" value="C:\Program Files\Java\jdk1.7.0\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0\jre\classes"/>
  55
+    <property name="java.vendor" value="Oracle Corporation"/>
  56
+    <property name="maven.home" value="C:\Users\Kestutis\git\Endgame-Oracle-local-repo\endgame-oracle\EMBEDDED"/>
  57
+    <property name="file.separator" value="\"/>
  58
+    <property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
  59
+    <property name="sun.cpu.endian" value="little"/>
  60
+    <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
  61
+    <property name="sun.desktop" value="windows"/>
  62
+    <property name="sun.cpu.isalist" value="amd64"/>
  63
+  </properties>
  64
+  <testcase time="0.65" classname="chess.ChessPositionTest" name="getPiecesToSquaresThrowsIllegalArgumentExceptionTest2"/>
  65
+  <testcase time="0" classname="chess.ChessPositionTest" name="getSquaresToPiecesMapThrowsIllegalArgumentExceptionTest1"/>
  66
+  <testcase time="0.065" classname="chess.ChessPositionTest" name="getWhitePiecesTest"/>
  67
+  <testcase time="0" classname="chess.ChessPositionTest" name="getWhiteSquaresTest"/>
  68
+  <testcase time="0.044" classname="chess.ChessPositionTest" name="getPiecesAndSquaresMapTest1"/>
  69
+  <testcase time="0" classname="chess.ChessPositionTest" name="getBlackSquaresTest"/>
  70
+  <testcase time="0.001" classname="chess.ChessPositionTest" name="getBlackPiecesTest"/>
  71
+</testsuite>
84  endgame-oracle/target/surefire-reports/TEST-chess.SquareTest.xml
... ...
@@ -0,0 +1,84 @@
  1
+<?xml version="1.0" encoding="UTF-8" ?>
  2
+<testsuite failures="0" time="0.048" errors="0" skipped="0" tests="20" name="chess.SquareTest">
  3
+  <properties>
  4
+    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
  5
+    <property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.7.0\jre\bin"/>
  6
+    <property name="java.vm.version" value="21.0-b17"/>
  7
+    <property name="user.country.format" value="GB"/>
  8
+    <property name="java.vm.vendor" value="Oracle Corporation"/>
  9
+    <property name="java.vendor.url" value="http://java.oracle.com/"/>
  10
+    <property name="path.separator" value=";"/>
  11
+    <property name="guice.disable.misplaced.annotation.check" value="true"/>
  12
+    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
  13
+    <property name="file.encoding.pkg" value="sun.io"/>
  14
+    <property name="user.script" value=""/>
  15
+    <property name="user.country" value="US"/>
  16
+    <property name="sun.java.launcher" value="SUN_STANDARD"/>
  17
+    <property name="sun.os.patch.level" value="Service Pack 1"/>
  18
+    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
  19
+    <property name="user.dir" value="C:\Users\Kestutis\git\Endgame-Oracle-local-repo\endgame-oracle"/>
  20
+    <property name="java.runtime.version" value="1.7.0-b147"/>
  21
+    <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
  22
+    <property name="java.endorsed.dirs" value="C:\Program Files\Java\jdk1.7.0\jre\lib\endorsed"/>
  23
+    <property name="os.arch" value="amd64"/>
  24
+    <property name="java.io.tmpdir" value="C:\Users\Kestutis\AppData\Local\Temp\"/>
  25
+    <property name="line.separator" value="
  26
+"/>
  27
+    <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
  28
+    <property name="user.variant" value=""/>
  29
+    <property name="os.name" value="Windows 7"/>
  30
+    <property name="classworlds.conf" value="C:\Users\Kestutis\workspace\.metadata\.plugins\org.eclipse.m2e.core\launches\m2conf3775194200877297841.tmp"/>
  31
+    <property name="sun.jnu.encoding" value="Cp1252"/>
  32
+    <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;;."/>
  33
+    <property name="java.specification.name" value="Java Platform API Specification"/>
  34
+    <property name="java.class.version" value="51.0"/>
  35
+    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
  36
+    <property name="os.version" value="6.1"/>
  37
+    <property name="user.home" value="C:\Users\Kestutis"/>
  38
+    <property name="user.timezone" value="Europe/London"/>
  39
+    <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
  40
+    <property name="java.specification.version" value="1.7"/>
  41
+    <property name="file.encoding" value="UTF-8"/>
  42
+    <property name="user.name" value="Kestutis"/>
  43
+    <property name="java.class.path" value="/C:/Users/Kestutis/eclipse/configuration/org.eclipse.osgi/bundles/814/1/.cp/jars/plexus-classworlds-2.4.jar"/>