Skip to content

Commit

Permalink
copy constructor for board
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Apr 20, 2016
1 parent 1b3d63e commit 8150181
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ public Board() {
movesSinceCapture = 0;
init();
}

/**
* Copy constructor.
* @param other
*/
public Board(Board other) {
this.representation = new Piece[BOARD_SIZE][BOARD_SIZE];
Piece[][] other_representation = other.getRepresentation();
for (int i = 0; i < other_representation.length; ++i) {
for (int j = 0; j < other_representation[0].length; ++j) {
this.representation[i][j] = other_representation[i][j];
}
}
movesSinceCapture = other.getMovesSinceCapture();
}

public boolean isValidSquare(int row, int col) {
return 0 <= row && row < BOARD_SIZE &&
Expand Down Expand Up @@ -62,6 +77,12 @@ public boolean equals(Board other) {
return true;
}

public ArrayList<Board> generateMoveFrontier(Color color) {
ArrayList<Board> frontier = new ArrayList<Board>();


}

/**
* Generates the frontier.
* @param color The color of pieces to generate the frontier for.
Expand Down Expand Up @@ -126,6 +147,10 @@ public void setBlackPieces(ArrayList<Piece> black_pieces) {

public Piece[][] getRepresentation() {
return this.representation;
}

public int getMovesSinceCapture() {
return this.movesSinceCapture;
}
}

0 comments on commit 8150181

Please sign in to comment.