public int compareTo ( Piece other ) { // return true for the same pieces, otherwise sort by time seen, then by index; if ( this . equals ( other ) ) { return 0 ; } else if ( this . seen == other . seen ) { return new Integer ( this . index ) . compareTo ( other . index ) ; } else if ( this . seen < other . seen ) { return - 1 ; } else { return 1 ; } }
Piece comparison function for ordering pieces based on their availability .