Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Apr 21, 2016
2 parents c7d42f0 + f48a92e commit 185b9da
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,29 @@ public ArrayList<Move> generateMoves(Piece p) {
up = p.getColor() == Color.BLACK || p.getType() == Type.KING;
down = p.getColor() == Color.RED || p.getType() == Type.KING;
if (up) {
// up left
Move upLeft = new Move(p.getLocation(), new Location(row - 1, col - 1));
if (isValidMove(upLeft)) {
avail_moves.add(new Move(p.getLocation(), new Location(row - 1, col - 1)));
avail_moves.add(upLeft);
}

// up right
Move upRight = new Move(p.getLocation(), new Location(row - 1, col + 1));
if (isValidMove(upRight)) {
avail_moves.add(new Move(p.getLocation(), new Location(row - 1, col + 1)));
avail_moves.add(upRight);
}
}
if (down) {
// down left
Move downLeft = new Move(p.getLocation(), new Location(row + 1, col - 1));
if (isValidMove(downLeft)) {
avail_moves.add(new Move(p.getLocation(), new Location(row + 1, col - 1)));
avail_moves.add(downLeft);
}

// down right
Move downRight = new Move(p.getLocation(), new Location(row + 1, col + 1));
if (isValidMove(downRight)) {
avail_moves.add(new Move(p.getLocation(), new Location(row + 1, col + 1)));
avail_moves.add(downRight);
}
}
return avail_moves;
Expand All @@ -127,8 +128,8 @@ public ArrayList<Board> generateMoveFrontier(Color color) {
for (int j = 0; j < BOARD_SIZE; ++j) {
Piece p = this.representation[i][j];
if(null != p && p.getColor() == color) {
ArrayList<Move> jump_moves = generateMoves(this.representation[i][j]);
for (Move move : jump_moves) {
ArrayList<Move> moves = generateMoves(this.representation[i][j]);
for (Move move : moves) {
Board board = new Board(this);
board.move(move);
frontier.add(board);
Expand Down

0 comments on commit 185b9da

Please sign in to comment.