void solveCross(int row, int col)
{
    if (!testPiece(row, col, 0))
    {
        return;
    }

    placePiece(row, col, 0);

    if (!prune())
    {
        const int rowMax = 8 - pieceMin[lastPiece + 1];
        for (int orient = 0; orient < orientMax[lastPiece + 1]; ++orient)
        {
            if (pieceRow[0] == pieceCol[0] && pieceRow[1] == pieceCol[1] && 0 < orient)
            {
                // Special case: if symmetric about diagonal, use only one line orientation.
                break;
            }
            for (int row = 0; row <= rowMax; ++row)
            {
                for (int col = 0; col <= rowMax; ++col)
                {
                    solvePiece(row, col, orient);
                }
            }
        }
    }

    removePiece();
}
Exemplo n.º 2
0
void IntegrationTest::testError1()
{
    /*
      This:
      *__________*
      *          *03
      *          *02
      *    OO    *01
      *XXXXOOXXXX*00
      *0123456789*
      Should become this
      *__________*
      *          *03
      *          *02
      *          *01
      *    XX    *00
      *0123456789*
      Observed error, becomes this:
      *__________*
      *          *03
      *          *02
      *     X    *01
      *    X     *00
      *0123456789*
      */
    Field testField;
    Piece testPiece(O,0,&testField);

    for(int i=0; i<4; ++i)
    {
        testField.set(i,0);
    }
    for(int i=6; i<10; ++i)
    {
        testField.set(i,0);
    }
    testPiece.handleInput(hard_drop);

    CPPUNIT_ASSERT( testField.get(4,0) );
    CPPUNIT_ASSERT( testField.get(5,0) );
    CPPUNIT_ASSERT(!testField.get(4,1) );
    CPPUNIT_ASSERT(!testField.get(5,1) );
}
void solvePiece(int row, int col, int orient)
{
    if (!testPiece(row, col, orient))
    {
        return;
    }

    placePiece(row, col, orient);

    if (lastPiece == 12)
    {
        if(isChess()){
            ++solutionCount;
            printSolution();
            printBoard();
        }
    }
    else
    {
        if (!prune())
        {
            const int rowMax = 8 - pieceMin[lastPiece + 1];
            for (int orient = 0; orient < orientMax[lastPiece + 1]; ++orient)
            {
                for (int row = 0; row <= rowMax; ++row)
                {
                    for (int col = 0; col <= rowMax; ++col)
                    {
                        solvePiece(row, col, orient);
                    }
                }
            }
        }
    }

    removePiece();
}