From d868467609d662bf64d0285dbff4a30e0a2629da Mon Sep 17 00:00:00 2001 From: John Bojorquez Date: Wed, 20 Apr 2016 20:33:57 -0400 Subject: [PATCH 1/2] Refactored some stuff to shorten the code --- src/model/Board.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/model/Board.java b/src/model/Board.java index c941cfe..4c77629 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -89,28 +89,29 @@ public ArrayList 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; From f48a92ec6b72fd85f231154a368e36dc82b393a3 Mon Sep 17 00:00:00 2001 From: John Bojorquez Date: Wed, 20 Apr 2016 20:34:34 -0400 Subject: [PATCH 2/2] Refactored some stuff to shorten the code --- src/model/Board.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/model/Board.java b/src/model/Board.java index 4c77629..6ead63b 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -128,8 +128,8 @@ public ArrayList generateMoveFrontier(Color color) { for (int j = 0; j < BOARD_SIZE; ++j) { Piece p = this.representation[i][j]; if(null != p && p.getColor() == color) { - ArrayList jump_moves = generateMoves(this.representation[i][j]); - for (Move move : jump_moves) { + ArrayList moves = generateMoves(this.representation[i][j]); + for (Move move : moves) { Board board = new Board(this); board.move(move); frontier.add(board);