Ejemplo n.º 1
0
void ChessBoard::generateMoves(int sq, Moves& mvs)
{
    int pc = m_data[sq];
    if (!pc) return;
    switch (pieceType(pc)) {
    case PIECE_KING:
        generateKingMoves(*this, sq, mvs);
        break;
    case PIECE_ADVISOR:
        generateAdvisorMoves(*this, sq, mvs);
        break;
    case PIECE_BISHOP:
        generateBishopMoves(*this, sq, mvs);
        break;
    case PIECE_KNIGHT:
        generateKnightMoves(*this, sq, mvs);
        break;
    case PIECE_ROOK:
        generateRookMoves(*this, sq, mvs);
        break;
    case PIECE_CANNON:
        generateCannonMoves(*this, sq, mvs);
        break;
    case PIECE_PAWN:
        generatePawnMoves(*this, sq, mvs);
        break;

    }
}
Ejemplo n.º 2
0
void BoardSetupDialog::slotInvalidMove(Square from)
{
    Board b = ui.boardView->board();
    Piece p = b.pieceAt(from);
    if(pieceType(p) != King)
    {
        b.removeFrom(from);
        setBoard(b);
    }
}
Ejemplo n.º 3
0
void AnalysisWidget::showTablebaseMove(Move move, int score)
{
    QString result;
    if(score == 0)
    {
        result = tr("Draw");
    }
    else if((score < 0) == (m_board.toMove() == Black))
    {
        result = tr("White wins in %n moves", "", qAbs(score));
    }
    else
    {
        result = tr("Black wins in %n moves", "", qAbs(score));
    }

    Move move1 = m_board.prepareMove(move.from(), move.to());
    if(move.isPromotion())
    {
        move1.setPromoted(pieceType(move.promotedPiece()));
    }
    m_tablebaseEvaluation = QString("%1 - %2").arg(m_board.moveToFullSan(move1)).arg(result);
    updateAnalysis();
}