chessai
college code for ai playing chess in java
git clone https://9o.is/git/chessai.git
commit f6e3c5283f8ce218a18f211fdfe3e97e22c238d1 parent 8693421bbd5af4e097362844ba39b1aca78eebcd Author: Jul <jul@9o.is> Date: Thu, 6 Dec 2012 14:18:32 -0500 Get player's pieces' coordinates Diffstat:
| M | src/main/java/chess/ChessBoard.java | | | 14 | ++++++++++++++ |
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/main/java/chess/ChessBoard.java b/src/main/java/chess/ChessBoard.java @@ -2,6 +2,9 @@ package chess; import chess.utils.ChessDirection; +import java.util.ArrayList; +import java.util.List; + /** * */ @@ -69,6 +72,17 @@ public class ChessBoard { return false; } + public List<ChessCoordinate> getPlayerPieces(ChessPlayer player) { + List<ChessCoordinate> playerPieces = new ArrayList<ChessCoordinate>(); + for(int i=1; i<=ChessCoordinate.MAX; i++) + for(int j=1; j<=ChessCoordinate.MAX; j++) { + ChessPiece piece = ChessPiece.find(state.get(new ChessCoordinate(j,i))); + if(piece.getColor() == player.getColor()) + playerPieces.add(new ChessCoordinate(j,i)); + } + return playerPieces; + } + //CHECK public String printState() { byte[][] state = this.state.getState();