Permalink
Please sign in to comment.
Browse files
Few steps further, added search possible fits for single position free
situation
- Loading branch information...
Showing
with
467 additions
and 28 deletions.
- +26 −0 Puzzler/src/main/org/geenz/puzzler/Coordinate.java
- +131 −8 Puzzler/src/main/org/geenz/puzzler/Grid.java
- +52 −0 Puzzler/src/main/org/geenz/puzzler/Piece.java
- +73 −0 Puzzler/src/main/org/geenz/puzzler/Pieces.java
- +26 −0 Puzzler/src/main/org/geenz/puzzler/PlacedPiece.java
- +50 −20 Puzzler/src/test/org/geenz/puzzler/PieceTest.java
- +109 −0 Puzzler/src/test/org/geenz/puzzler/SolverTest.java
@@ -0,0 +1,26 @@ | ||
+package org.geenz.puzzler; | ||
+ | ||
+public class Coordinate { | ||
+ | ||
+ int x = 0; | ||
+ int y = 0; | ||
+ | ||
+ public Coordinate(int x, int y) { | ||
+ this.x = x; | ||
+ this.y = y; | ||
+ } | ||
+ | ||
+ public int getX() { | ||
+ return x; | ||
+ } | ||
+ | ||
+ public int getY() { | ||
+ return y; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public boolean equals(Object obj) { | ||
+ Coordinate other = (Coordinate) obj; | ||
+ return (other.getX() == getX() && other.getY() == getY()); | ||
+ } | ||
+} |
@@ -0,0 +1,73 @@ | ||
+package org.geenz.puzzler; | ||
+ | ||
+import java.util.Map; | ||
+import java.util.TreeMap; | ||
+ | ||
+public class Pieces { | ||
+ public final static Piece pieceA = new Piece(new char[][] { | ||
+ { 'A', 'A' }, | ||
+ { '0', 'A' }, | ||
+ { '0', 'A' }}); | ||
+ public final static Piece pieceB = new Piece(new char[][] { | ||
+ { 'B', 'B' }, | ||
+ { 'B', 'B' }, | ||
+ { '0', 'B' }}); | ||
+ public final static Piece pieceC = new Piece(new char[][] { | ||
+ { 'C', 'C' }, | ||
+ { '0', 'C' }, | ||
+ { '0', 'C' }, | ||
+ { '0', 'C' }}); | ||
+ public final static Piece pieceD = new Piece(new char[][] { | ||
+ { '0', 'D' }, | ||
+ { 'D', 'D' }, | ||
+ { '0', 'D' }, | ||
+ { '0', 'D' }}); | ||
+ public final static Piece pieceE = new Piece(new char[][] { | ||
+ { 'E', '0' }, | ||
+ { 'E', 'E' }, | ||
+ { '0', 'E' }, | ||
+ { '0', 'E' }}); | ||
+ public final static Piece pieceF = new Piece(new char[][] { | ||
+ { 'F', 'F' }, | ||
+ { '0', 'F' }}); | ||
+ public final static Piece pieceG = new Piece(new char[][] { | ||
+ { 'G', 'G', 'G' }, | ||
+ { '0', '0', 'G' }, | ||
+ { '0', '0', 'G'}}); | ||
+ public final static Piece pieceH = new Piece(new char[][] { | ||
+ { 'H', 'H', '0' }, | ||
+ { '0', 'H', 'H' }, | ||
+ { '0', '0', 'H'}}); | ||
+ public final static Piece pieceI = new Piece(new char[][] { | ||
+ { 'I', '0', 'I' }, | ||
+ { 'I', 'I', 'I'}}); | ||
+ public final static Piece pieceJ = new Piece(new char[][] { | ||
+ { 'J' }, | ||
+ { 'J' }, | ||
+ { 'J' }, | ||
+ { 'J' }}); | ||
+ public final static Piece pieceK = new Piece(new char[][] { | ||
+ { 'K', 'K' }, | ||
+ { 'K', 'K' }}); | ||
+ public final static Piece pieceL = new Piece(new char[][] { | ||
+ { '0', 'L', '0' }, | ||
+ { 'L', 'L', 'L' }, | ||
+ { '0', 'L', '0'}}); | ||
+ | ||
+ public final static Map<Character, Piece> pieces = new TreeMap<Character, Piece>(); | ||
+ | ||
+ static { | ||
+ pieces.put('A', pieceA); | ||
+ pieces.put('B', pieceB); | ||
+ pieces.put('C', pieceC); | ||
+ pieces.put('D', pieceD); | ||
+ pieces.put('E', pieceE); | ||
+ pieces.put('F', pieceF); | ||
+ pieces.put('G', pieceG); | ||
+ pieces.put('H', pieceH); | ||
+ pieces.put('I', pieceI); | ||
+ pieces.put('J', pieceJ); | ||
+ pieces.put('K', pieceK); | ||
+ pieces.put('L', pieceL); | ||
+ } | ||
+} |
@@ -0,0 +1,26 @@ | ||
+package org.geenz.puzzler; | ||
+ | ||
+public class PlacedPiece { | ||
+ | ||
+ private Piece piece = null; | ||
+ private Coordinate coordinate = null; | ||
+ private int orientation = Piece.DEFAULT_ORIENTATION; | ||
+ | ||
+ public PlacedPiece(Piece piece, Coordinate coordinate, int orientation) { | ||
+ this.piece = piece; | ||
+ this.coordinate = coordinate; | ||
+ this.orientation = orientation; | ||
+ } | ||
+ | ||
+ public Coordinate getCoordinate() { | ||
+ return coordinate; | ||
+ } | ||
+ | ||
+ public Piece getPiece() { | ||
+ return piece; | ||
+ } | ||
+ | ||
+ public int getOrientation() { | ||
+ return orientation; | ||
+ } | ||
+} |

Oops, something went wrong.
0 comments on commit
3b4651d