* @throws GameException Illegal move.
*/
protected void play(int pos, byte color, boolean allowIllegal) throws GameException {
if (!allowIllegal) {
if (board.get(pos) != Board.NONE) {
SGFPoint p = board.xy(pos);
throw new GameOverStoneException("Stone " + board.get(pos) + " already at " + p.x + "," + p.y);
}
if (pos == koMove)
throw new GameKoMoveException();
if (color != colorToPlay)
throw new GameWrongHandException("Expected: " + colorToPlay + ", got: " + color);
//System.out.println("Move expected: " + colorToPlay + ", got: " + color);
}
advance();
set(pos, color);
Group deadGroup = new Group(board.maxPos());
byte otherColor = Board.other(color);
// collect dead stones
board.clearBits(Board.M_DEAD);
collectDead(board.n(pos), otherColor, deadGroup);
collectDead(board.e(pos), otherColor, deadGroup);
collectDead(board.s(pos), otherColor, deadGroup);
collectDead(board.w(pos), otherColor, deadGroup);
if (deadGroup.size == 0) {
// no deaders, check if suicide
board.getGroup(pos, deadGroup);
if (deadGroup.liberties == 0) {
if (!allowIllegal) {
set(pos, Board.NONE);
history.pop();
SGFPoint p = board.xy(pos);
throw new GameSuicideMoveException(p.x + "," + p.y);
} // else we remove suicidal group
} else
deadGroup.size = 0;
}