2 * agent++ : A Sample agent for UCC::Progcomp2013
4 * @purpose Declarations for game related classes; Piece, Square, Board
11 // board height and width (don't change!)
12 #define BOARD_HEIGHT 8
23 * @purpose Represent a quantum chess piece
28 Piece(int x, int y, const std::string & new_colour, const std::string & type1 = "unknown", const std::string & type2 = "unknown", int new_type_index = -1); // constructor
29 Piece(const Piece & cpy); // copy constructor
30 virtual ~Piece() {} // destructor
32 int x; int y; // position of the piece
33 std::string colour; // colour of the piece
34 int type_index; // indicates state the piece is in; 0, 1, or -1 (unknown)
35 std::string types[2]; // states of the piece
36 std::string current_type; // current state of the piece
43 * @purpose Represent a Square on the board; not necessarily occupied
48 Square() : x(-1), y(-1), piece(NULL) {} // constructor
49 Square(int new_x, int new_y, Piece * new_piece = NULL) : x(new_x), y(new_y), piece(new_piece) {} //UNUSED
50 Square(const Square & cpy) : x(cpy.x), y(cpy.y), piece(cpy.piece) {} // copy constructor (UNUSED)
51 virtual ~Square() {} //destructor
52 int x; int y; // position of the square
53 Piece * piece; // Piece that is in the Square (NULL if unoccupied)
58 * @purpose Represent a quantum chess board
63 Board(bool choose_types = false); // constructor
64 Board(const Board & cpy); // copy constructor
65 virtual ~Board(); // destructor
68 // helper; return vector of pieces given player colour
69 std::vector<Piece*> & pieces(const std::string & colour) {return ((colour == "white") ? white : black);}
70 // helper; return king given player colour
71 Piece * king(const std::string & colour) {return ((colour == "white") ? white_king : black_king);}
73 void Update_move(int x, int y, int x2, int y2); // move a piece
74 void Update_select(int x, int y, int index, const std::string & type); // update a selected piece
76 Square & square(int x, int y) {return grid[x][y];} // get square on board
78 void Get_moves(Piece * p, std::vector<Square*> & v); // get allowed moves for piece
80 // determine if position is on the board
81 bool Valid_position(int x, int y) {return (x >= 0 && x <= BOARD_WIDTH-1 && y >= 0 && y <= BOARD_HEIGHT-1);}
84 Square grid[BOARD_WIDTH][BOARD_HEIGHT];
87 std::vector<Piece*> white;
88 std::vector<Piece*> black;
92 // Add a move to the vector if it is valid
93 void Move(Piece * p, int x, int y, std::vector<Square*> & v);
95 // Add all valid moves in a direction, stopping at the first invalid move
96 void Scan(Piece * p, int vx, int vy, std::vector<Square*> & v);