Sorry this has probably been answered somewhere but I'm pretty new to Java and I can't apply other answers I have found to the work I'm doing.
So I have an ArrayList which stores locations of pieces it can take on that particular turn.
ArrayList<Move> legalTakes = new ArrayList<Move>();
A move has a co-ordinate from (x1,y1) and a co-ordinate to (x2,y2) which is where the piece it will be taking is at.
moveInput = new Move(pieceToMove, x1, y1, x2, y2, false);
From calling a method (getPiece) I can take the x2,y2 and see which piece is at that location and find the value of that piece.
for (Move m : legalTakes) { //for all of the possible takes that turn...
Piece occPieceToTake = this.getBoard().getPiece(m.getX2(),m.getY2());
int pieceValue = this.getBoard().getPiece(m.getX2(),m.getY2()).getValue(occPieceToTake.getChar());
System.err.println("-- WORTH : "+pieceValue);
}
From this is it possible to order my ArrayList based on the value returned by pieceValue? So if a king is returned with a value of 6, I can select that over a pawn which will return a value of 1?
Hope this is sufficient information..if not please let me know.