Example #1
0
def test_Assemble_ReturnsCorrectPreOrderTraversalTuple_1():
    moves1 = [
        BlackMove(0, 0),
        WhiteMove(0, 1),
        BlackMove(0, 2),
    ]
    moves2 = [
        BlackMove(1, 0),
        WhiteMove(1, 1),
        BlackMove(0, 2),
    ]

    assembler = Assembler(moves1)
    assembler.assemble(moves2)

    actual = to_tuple(assembler)

    expected = (
        Root(),
        BlackMove(0, 0),
        WhiteMove(0, 1),
        BlackMove(0, 2),
        BlackMove(1, 0),
        WhiteMove(1, 1),
        BlackMove(0, 2),
    )

    assert actual == expected
Example #2
0
def test_Assemble_C6FlagEnabled_ReturnsCorrectTuple_case7():
    moves1 = [
        BlackMove(9, 9),
        WhiteMove(9, 8),
        WhiteMove(8, 9),
        BlackMove(8, 8),
        BlackMove(7, 10)
    ]
    moves2 = [
        BlackMove(9, 9),
        WhiteMove(9, 8),
        WhiteMove(8, 9),
        BlackMove(8, 8),
        BlackMove(10, 7)
    ]
    assembler = Assembler(moves1, merge_symmetric_moves=True)
    assembler.assemble(moves2)

    actual = to_tuple(assembler)
    expected = (
        Root(),
        BlackMove(9, 9),
        WhiteMove(8, 9),
        WhiteMove(9, 8),
        BlackMove(8, 8),
        BlackMove(7, 10),
    )
    assert actual == expected
Example #3
0
def test_Assemble_ReturnsCorrectPreOrderTraversalTuple_4():
    assembler = Assembler()
    assembler.assemble([])

    actual = to_tuple(assembler)

    expected = (Root(), )

    assert actual == expected
Example #4
0
def test_Ctor_ReturnsCorrectPreOrderTraversalTuple():
    moves = [
        BlackMove(0, 0),
        WhiteMove(0, 1),
        BlackMove(0, 2),
    ]

    assembler = Assembler(moves)

    actual = to_tuple(assembler)
    expected = (Root(), BlackMove(0, 0), WhiteMove(0, 1), BlackMove(0, 2))

    assert actual == expected
    assert type(actual) == tuple
Example #5
0
    def __init__(self,
                 moves=None,
                 url="_sample_url_",
                 *,
                 game_results="Draw",
                 merge_symmetric_moves=False):
        self.root = AnyNode(data=Root(),
                            parent=None,
                            visit_cnt=0,
                            urls=[],
                            bwin=0,
                            wwin=0,
                            draw=0,
                            is_a_chosen_opening=False,
                            is_terminate_node=False)

        self.merge_symmetric_moves = merge_symmetric_moves

        if moves:
            self.assemble(moves, url, game_results)
Example #6
0
def test_Assemble_mergeSymmetricMoves_ReturnsCorrectPreOrderTraversalTuple_0():
    moves1 = [BlackMove(0, 0), WhiteMove(2, 1), BlackMove(0, 2)]
    moves2 = [
        BlackMove(0, 18),
        WhiteMove(1, 16),
        BlackMove(2, 18),
    ]  # Rotate 90%
    moves3 = [
        BlackMove(18, 18),
        WhiteMove(16, 17),
        BlackMove(18, 16),
    ]  # Rotate 180%
    moves4 = [
        BlackMove(18, 0),
        WhiteMove(17, 2),
        BlackMove(16, 0),
    ]  # Rotate 270%
    moves5 = [
        BlackMove(0, 18),
        WhiteMove(2, 17),
        BlackMove(0, 16),
    ]  # Horizontal reflection

    assembler = Assembler(moves1, merge_symmetric_moves=True)
    assembler.assemble(moves2)
    assembler.assemble(moves3)
    assembler.assemble(moves4)
    assembler.assemble(moves5)

    actual = to_tuple(assembler)

    expected = (
        Root(),
        BlackMove(0, 0),
        WhiteMove(1, 2),
        BlackMove(2, 0),
    )

    assert actual == expected
Example #7
0
def test_Assemble_C6FlagEnabled_ReturnsCorrectTuple_case1():
    moves1 = [
        BlackMove(9, 9),
        WhiteMove(11, 7),
        WhiteMove(12, 6),
        BlackMove(11, 11),
        BlackMove(12, 12),
        WhiteMove(11, 3),
        WhiteMove(12, 3),
        BlackMove(9, 3),
        BlackMove(8, 3)
    ]

    moves2 = [
        BlackMove(9, 9),
        WhiteMove(7, 11),
        WhiteMove(6, 12),
        BlackMove(11, 11),
        BlackMove(12, 12),
        WhiteMove(11, 3),
        WhiteMove(12, 3),
        BlackMove(9, 3),
        BlackMove(8, 3)
    ]

    assembler = Assembler(moves1, merge_symmetric_moves=True)
    assembler.assemble(moves2)
    expected = (Root(), BlackMove(9, 9), WhiteMove(6, 6), WhiteMove(7, 7),
                BlackMove(6, 12), BlackMove(7, 11), WhiteMove(6, 3),
                WhiteMove(7, 3), BlackMove(9,
                                           3), BlackMove(10,
                                                         3), WhiteMove(15, 11),
                WhiteMove(15, 12), BlackMove(15, 8), BlackMove(15, 9))

    actual = to_tuple(assembler)

    assert actual == expected