X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/FreeShisen/blobdiff_plain/ce8b3d2450bd5d04eeb8c60b043c66dd4a1fc670..92b19250a620252d642c0abaf8dd3d733c299f3d:/src/de/cwde/shisensho/Board.java diff --git a/src/de/cwde/shisensho/Board.java b/src/de/cwde/shisensho/Board.java deleted file mode 100644 index 146b1d8..0000000 --- a/src/de/cwde/shisensho/Board.java +++ /dev/null @@ -1,389 +0,0 @@ -package de.cwde.shisensho; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -public class Board { - private static String charpieces = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - - public int difficulty=1; // 1=Hard ... N=Easy - public boolean gravity=true; - public int [] boardSize; - public char[][] board; - public LinkedList history; - - // ---------------------- - // Public methods - // ---------------------- - - public Board() { - } - - // The board always has a 1-square width free rectangle that has - // to be taken into account when specifying the size - public void initialize(int sizeI, int sizeJ) { - boardSize = new int[2]; - boardSize[0]=sizeI; - boardSize[1]=sizeJ; - board = new char[boardSize[0]][boardSize[1]]; - for (int i=0;i(); - } - - public static String pieceToString(char piece) { - return charpieces.substring(piece,1); - } - - public static char StringToPiece(String piece) { - char upiece; - long charpiecesLen=charpieces.length(); - for(upiece=0;(upiece0) result+=" "; - result+=""+(j%10); - } - result+="\n "+StringRepeat("--",boardSize[1]); - for (int i=0;i0) result+=" "; - result+=charpieces.substring(board[i][j],board[i][j]+1); - } - result+=" |\n"; - if (i getPairs(int maxResults) { - List result=new ArrayList(); - List pieces=new ArrayList(); - List> piecePoints=new ArrayList>(); - for (int i=0;i points0=new ArrayList(); - points0.add(p); - pieces.add(piece); - piecePoints.add(points0); - - key=pieces.indexOf(piece); - piecePoints.get(key); - } else { - List points1=piecePoints.get(key); - points1.add(p); - } - } - - int nresults=0; - for (List points : piecePoints) { - int n=(int)points.size(); - for (int i=0;i path=getPath(a.copy(),b.copy()); - if (path!=null && path.size()>0) { - result.add(new Line(a,b)); - if (nresults++==maxResults) break; - } - } - if (nresults==maxResults) break; - } - if (nresults==maxResults) break; - } - return result; - } - - public int getNumPieces() { - int result=0; - for (int j=0;j getHorizontalLines(Point excludeA, Point excludeB) { - List result=new ArrayList(); - for (int i=0;i getVerticalLines(Point excludeA, Point excludeB) { - List result=new ArrayList(); - for (int j=0;j0;i--) board[i][p.j]=board[i-1][p.j]; - } - - private void undoGravity(Point p) { - if (gravity) for (int i=0;i