private GoCaptureList determineCaptures(GoBoardPosition stone) {
profiler_.startFindCaptures();
assert ( stone != null );
GoBoardPositionSet nbrs = nbrAnalyzer_.getNobiNeighbors( stone, NeighborType.ENEMY );
GoCaptureList captureList = new GoCaptureList();
// keep track of the strings captured so we don't capture the same one twice
GoStringSet capturedStrings = new GoStringSet();
for (GoBoardPosition enbr : nbrs) {
assert (enbr.isOccupied()): "enbr=" + enbr;
IGoString str = enbr.getString();
assert ( str.isOwnedByPlayer1() != stone.getPiece().isOwnedByPlayer1()):
"The "+str+" is not an enemy of "+stone;
assert ( str.size() > 0 ) : "Sting has 0 stones:" + str;
if ( str.getNumLiberties(getBoard()) == 0 && !capturedStrings.contains(str) ) {
capturedStrings.add( str );
// we need to add copies so that when the original stones on the board are
// changed we don't change the captures.
captureList.addCaptures(str.getMembers());
}
}
profiler_.stopFindCaptures();
return captureList;
}