change draw
This commit is contained in:
@@ -280,14 +280,15 @@ public class ChessBoard {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int hashPlayerPieces(Color color) {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < Coordinate.VALUE_MAX; i++) {
|
||||
for (int j = 0; j < Coordinate.VALUE_MAX; j++) {
|
||||
Piece piece = pieceAt(new Coordinate(i, j));
|
||||
if (piece == null || piece.getColor() != color)
|
||||
if (piece == null)
|
||||
continue;
|
||||
result = Objects.hash(result, new Coordinate(i, j), piece);
|
||||
result = Objects.hash(result, piece.getColor(), new Coordinate(i, j), piece);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -302,10 +303,10 @@ public class ChessBoard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object otherBoard){
|
||||
if (!(otherBoard instanceof ChessBoard)) return false;
|
||||
return ((hashPlayerPieces(Color.White) == ((ChessBoard)otherBoard).hashPlayerPieces(Color.White))
|
||||
&& (hashPlayerPieces(Color.Black) == ((ChessBoard)otherBoard).hashPlayerPieces(Color.Black)));
|
||||
public boolean equals(Object obj){
|
||||
if (obj instanceof ChessBoard board)
|
||||
return board.hashCode() == this.hashCode();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user