void Tree::addEmptyMove( bool /*brother*/) { // qDebug("BoardHandler::createMoveSGF() - %d", mode); Move *m; Matrix *mat = current->getMatrix(); m = new Move(stoneBlack, -1, -1, current->getMoveNumber()+1, phaseOngoing, *mat, true); /*else //fastload { m = new Move(stoneBlack, -1, -1, current->getMoveNumber()+1, phaseOngoing); }*/ #ifdef FIXME if (!brother && hasSon(m)) { /* FIXME in loading that Kogo's joseki dictionary we get * about 20 of these, probably sources to a sgfparser issue */ /* Okay, as far as I know, this function is never called with * "brother", so it just always does addSon. * Then addSon will add a brother if it should be a brother. * Obviously this needs clarification */ qDebug("*** HAVE THIS SON ALREADY! ***"); delete m; return; } #endif //FIXME /* Below removed since brother never used */ //if (!brother) addSon(m); //else // addBrother(m); }
void TCODBsp::splitOnce(bool horizontal, int position) { this->horizontal = horizontal; this->position=position; addSon(new TCODBsp(this,true)); addSon(new TCODBsp(this,false)); }
void Tree::addMove(StoneColor c, int x, int y) { Move * lastValidMoveChecked = new Move(c, x, y, current->getMoveNumber() + 1, phaseOngoing, *(current->getMatrix()), true); //clearMarks = true koStoneX = 0; koStoneY = 0; /* special case: pass */ if(x == 20 && y == 20) { if (hasSon(lastValidMoveChecked)) delete lastValidMoveChecked; else addSon(lastValidMoveChecked); return; } if (insertStoneFlag) { insertStone(lastValidMoveChecked); return; } if (c == stoneErase) { /* FIXME I don't think this is right. First of all, it needs to be fixed in deleteNode() as well which is called as an undo * as well as as a tree edit. But here, I don't think we want a new move added as a son to erase a move, I think we just * want to erase it... or maybe not because it makes sense to add it as a tree when its an undo in a game. * another point is that its not like a move in order, its like a separate tree, so addMove(stoneErase seems singularly * useless since we have to do something special with the tree anyway, i.e., no addSon, but maybe we go backwards and * delete some marker */ lastValidMoveChecked->getMatrix()->insertStone(x, y, stoneErase); } if (hasSon(lastValidMoveChecked)) { /* This happens a lot if we add a move that's already there * when really we're just playing along with the tree. * This would be the place to add any kind of tesuji testing * code */ delete lastValidMoveChecked; return; } int lastCaptures = lastValidMoveChecked->getMatrix()->makeMove(x, y, c); addSon(lastValidMoveChecked); if (lastCaptures == 1) checkAddKoMark(current->getColor(), current->getX(), current->getY(), current); int capturesBlack, capturesWhite; if (current->parent != NULL) { capturesBlack = current->parent->getCapturesBlack(); capturesWhite = current->parent->getCapturesWhite(); } else capturesBlack = capturesWhite = 0; if (c == stoneBlack) capturesBlack += lastCaptures; else if (c == stoneWhite) capturesWhite += lastCaptures; current->setCaptures(capturesBlack, capturesWhite); }