3 * @purpose Represent Quantum Chess Piece
11 * @purpose Represent a quantum chess piece
15 public enum Type {PAWN, BISHOP, KNIGHT, ROOK, QUEEN, KING, UNKNOWN};
16 public enum Colour {WHITE, BLACK};
18 public Piece(int new_x, int new_y, Colour new_colour, Type type1, Type type2)
22 this.colour = new_colour;
23 this.types = new Piece.Type[2];
24 this.types[0] = type1;
25 this.types[1] = type2;
29 public Piece(Piece cpy)
33 this.colour = cpy.colour;
34 this.types[0] = cpy.types[0];
35 this.types[1] = cpy.types[1];
36 this.type_index = cpy.type_index;
40 public int y; // position of the piece
41 public Piece.Colour colour; // colour of the piece
42 public int type_index; // indicates state the piece is in; 0, 1, or -1 (unknown)
43 public Piece.Type[] types; // states of the piece
44 public Piece.Type current_type; // current state of the piece
46 public static Piece.Type str2type(String str) throws Exception
48 if (str.compareTo("king") == 0)
49 return Piece.Type.KING;
50 else if (str.compareTo("queen") == 0)
51 return Piece.Type.QUEEN;
52 else if (str.compareTo("rook") == 0)
53 return Piece.Type.ROOK;
54 else if (str.compareTo("bishop") == 0)
55 return Piece.Type.BISHOP;
56 else if (str.compareTo("knight") == 0)
57 return Piece.Type.KNIGHT;
58 else if (str.compareTo("pawn") == 0)
59 return Piece.Type.PAWN;
60 else if (str.compareTo("unknown") == 0)
61 return Piece.Type.UNKNOWN;
63 throw new Exception("Piece.str2type - string " + str + " isn't a valid type");
66 public static Piece.Colour str2colour(String str) throws Exception
68 if (str.compareTo("white") == 0)
69 return Piece.Colour.WHITE;
70 else if (str.compareTo("black") == 0)
71 return Piece.Colour.BLACK;
74 throw new Exception("Piece.str2colour - string " + str + " isn't a valid colour");