Fixed index out of bounds.

Implemented CellPointer equals, hashcode.
This commit is contained in:
Woody Folsom
2012-04-29 13:40:27 -04:00
parent a756aa242d
commit 744ceb02f7
2 changed files with 33 additions and 0 deletions

View File

@@ -15,4 +15,29 @@ public class CellPointer {
public String toString() { public String toString() {
return "(" + r + "," + c +")"; 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;
}
} }

View File

@@ -57,6 +57,10 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
SearchResult bestResult = new SearchResult(Move.NONE,Integer.MIN_VALUE); SearchResult bestResult = new SearchResult(Move.NONE,Integer.MIN_VALUE);
if (validMoves.size() == 0) {
return bestResult;
}
for (Move nextMove : validMoves) { for (Move nextMove : validMoves) {
Board nextBoard = new Board(board); Board nextBoard = new Board(board);
@@ -91,6 +95,10 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
SearchResult bestResult = new SearchResult(Move.NONE,Integer.MAX_VALUE); SearchResult bestResult = new SearchResult(Move.NONE,Integer.MAX_VALUE);
if (validMoves.size() == 0) {
return bestResult;
}
for (Move nextMove : validMoves) { for (Move nextMove : validMoves) {
Board nextBoard = new Board(board); Board nextBoard = new Board(board);