quoridor/src/main/java/cz/xelfi/quoridor/Board.java
branchstatistics-and-elo
changeset 179 c5fbddc4c590
parent 178 4b78d4f028b3
child 219 d836818f5554
     1.1 --- a/quoridor/src/main/java/cz/xelfi/quoridor/Board.java	Thu Jan 07 22:34:17 2010 +0100
     1.2 +++ b/quoridor/src/main/java/cz/xelfi/quoridor/Board.java	Thu Jan 07 22:51:17 2010 +0100
     1.3 @@ -32,7 +32,6 @@
     1.4  import java.io.IOException;
     1.5  import java.io.Reader;
     1.6  import java.io.StringReader;
     1.7 -import java.io.StringWriter;
     1.8  import java.io.Writer;
     1.9  import java.util.ArrayList;
    1.10  import java.util.Arrays;
    1.11 @@ -357,15 +356,6 @@
    1.12          return new Board(board);
    1.13      }
    1.14  
    1.15 -    public static Board picture2board(String board) throws IllegalPositionException {
    1.16 -        try {
    1.17 -            return read(new StringReader(board));
    1.18 -        } catch (IOException ex) {
    1.19 -            // shall not happen, StringReader does not throw IOException
    1.20 -            throw (IllegalPositionException)new IllegalPositionException(ex.getMessage()).initCause(ex);
    1.21 -        }
    1.22 -    }
    1.23 -
    1.24      private static int assertChar(String s, int pos, char... ch) throws IOException {
    1.25          if (s.length() >= pos) {
    1.26              for (int i = 0; i < ch.length; i++) {
    1.27 @@ -702,20 +692,9 @@
    1.28       */
    1.29      @Override
    1.30      public String toString() {
    1.31 -        return Board.board2HashCode(this);
    1.32 +        return getCode();
    1.33      }
    1.34  
    1.35 -    public String boardToPicture() {
    1.36 -        StringWriter w = new StringWriter();
    1.37 -        try {
    1.38 -            write(w);
    1.39 -        } catch (IOException ex) {
    1.40 -            return ex.toString();
    1.41 -        }
    1.42 -        return w.toString();
    1.43 -    }
    1.44 -
    1.45 -    
    1.46      //
    1.47      // Validation methods
    1.48      //
    1.49 @@ -872,7 +851,7 @@
    1.50          return 17 * y + x;
    1.51      }
    1.52  
    1.53 -    public Board(String hashCode) throws IllegalStateException{
    1.54 +    Board(String hashCode) throws IllegalStateException{
    1.55          this.fences = new HashSet<Fence>();
    1.56          if((hashCode != null) && (hashCode.length() > 6)){
    1.57              char[]c = hashCode.toCharArray();
    1.58 @@ -920,7 +899,8 @@
    1.59          }
    1.60      }
    1.61  
    1.62 -    public static String board2HashCode(Board b){
    1.63 +    public final String getCode() {
    1.64 +        Board b = this;
    1.65          StringBuilder sb = new StringBuilder();
    1.66          for(Player p: b.getPlayers()){
    1.67              sb.append((char)(p.getColumn() + 'A'));