Exemplo n.º 1
0
void SolverTest::StepRight()
{
    Board board;
    int blockId = board.AddBlockH(0,0,4);
    VisitedNode visitedNodes;
    Step step;
    auto res = step.Solve(1, board, visitedNodes);
    QCOMPARE((int)res.size(), 0);
    QCOMPARE((int)visitedNodes.Children().size(), 2);
    QCOMPARE((int)step.Children().size(), 2);
    QCOMPARE(step.Children()[0].MoveDesc(), MoveDescription(blockId, Direction::Right, 1));
    QCOMPARE(step.Children()[1].MoveDesc(), MoveDescription(blockId, Direction::Right, 2));
}
Exemplo n.º 2
0
void SolverTest::vNodeAddH()
{
    VisitedNode root;
    Board board;
    board.AddBlockH(0,2,4);
    board.SetBlockF(3,4);
    QVERIFY2(!root.HadNodeBeforeCall(board), "0");
    QCOMPARE((int)root.Children().size(), 1);
    QCOMPARE((int)root.Children()[0].Children().size(), 1);
    QCOMPARE((int)root.Children()[0].Children()[0].Children().size(), 0);
    QCOMPARE(root.Children()[0].Position(), IntVector(2,0));
    QCOMPARE(root.Children()[0].Children()[0].Position(), IntVector(3,4));
}
Exemplo n.º 3
0
void SolverTest::vNodeAddHTwoPos()
{
    VisitedNode root;
    Board board;
    int blockId = board.AddBlockH(0,1,2);
    board.SetBlockF(4,6);
    root.HadNodeBeforeCall(board);
    board.MoveRight(blockId, 1);
    QVERIFY2(!root.HadNodeBeforeCall(board), "0");
    QCOMPARE((int)root.Children().size(), 2);
    QCOMPARE((int)root.Children()[0].Children().size(), 1);
    QCOMPARE((int)root.Children()[1].Children().size(), 1);
    QCOMPARE((int)root.Children()[0].Children()[0].Children().size(), 0);
    QCOMPARE((int)root.Children()[1].Children()[0].Children().size(), 0);
    QCOMPARE(root.Children()[0].Position(), IntVector(1,0));
    QCOMPARE(root.Children()[1].Position(), IntVector(2,0));
    QCOMPARE(root.Children()[0].Children()[0].Position(), IntVector(4,6));
    QCOMPARE(root.Children()[1].Children()[0].Position(), IntVector(4,6));
}