Fixed index out of bounds.
Implemented CellPointer equals, hashcode.
This commit is contained in:
@@ -15,4 +15,29 @@ public class CellPointer {
|
||||
public String toString() {
|
||||
return "(" + r + "," + c +")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + c;
|
||||
result = prime * result + r;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CellPointer other = (CellPointer) obj;
|
||||
if (c != other.c)
|
||||
return false;
|
||||
if (r != other.r)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,10 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
|
||||
SearchResult bestResult = new SearchResult(Move.NONE,Integer.MIN_VALUE);
|
||||
|
||||
if (validMoves.size() == 0) {
|
||||
return bestResult;
|
||||
}
|
||||
|
||||
for (Move nextMove : validMoves) {
|
||||
Board nextBoard = new Board(board);
|
||||
|
||||
@@ -91,6 +95,10 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
|
||||
SearchResult bestResult = new SearchResult(Move.NONE,Integer.MAX_VALUE);
|
||||
|
||||
if (validMoves.size() == 0) {
|
||||
return bestResult;
|
||||
}
|
||||
|
||||
for (Move nextMove : validMoves) {
|
||||
Board nextBoard = new Board(board);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user