Beispiel #1
0
def test_move_down_first_equal():
    initial_state = Board.from_matrix([[0, 0, 0, 0], [0, 0, 0, 0],
                                       [2, 0, 0, 0], [2, 0, 0, 0]])

    result = initial_state.move(Action.move_down).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [4, 0, 0, 0]])
Beispiel #2
0
def test_move_up_multiple_opposite():
    initial_state = Board.from_matrix([[0, 0, 0, 0], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [2, 4, 8, 16]])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result,
                  [[2, 4, 8, 16], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #3
0
def test_move_up_double_different_equal():
    initial_state = Board.from_matrix([[4, 0, 0, 0], [4, 0, 0, 0],
                                       [2, 0, 0, 0], [2, 0, 0, 0]])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result,
                  [[8, 0, 0, 0], [4, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #4
0
def test_move_left_empty():
    initial_state = Board.from_matrix([[0, 0, 0, 0], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #5
0
def test_move_up_multiple_columns():
    initial_state = Board.from_matrix([[0, 8, 2, 4], [0, 8, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result,
                  [[0, 16, 2, 4], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #6
0
def test_move_right_multiple_opposite():
    initial_state = Board.from_matrix([[2, 0, 0, 0], [4, 0, 0, 0],
                                       [8, 0, 0, 0], [16, 0, 0, 0]])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 2], [0, 0, 0, 4], [0, 0, 0, 8], [0, 0, 0, 16]])
Beispiel #7
0
def test_move_up_first_equal_with_follower():
    initial_state = Board.from_matrix([[2, 0, 0, 0], [2, 0, 0, 0],
                                       [2, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result,
                  [[4, 0, 0, 0], [2, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #8
0
def test_move_right_double_different_equal():
    initial_state = Board.from_matrix([[4, 4, 2, 2], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result,
                  [[0, 0, 8, 4], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #9
0
def test_move_right_middle_equal():
    initial_state = Board.from_matrix([[0, 2, 2, 0], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 4], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #10
0
def test_move_left_multiple_columns():
    initial_state = Board.from_matrix([[0, 0, 0, 0], [8, 8, 0, 0],
                                       [2, 0, 0, 0], [4, 0, 0, 0]])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 0], [16, 0, 0, 0], [2, 0, 0, 0], [4, 0, 0, 0]])
Beispiel #11
0
def test_move_right_first_equal_with_follower():
    initial_state = Board.from_matrix([[0, 2, 2, 2], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result,
                  [[0, 0, 2, 4], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #12
0
def test_move_left_double_equal():
    initial_state = Board.from_matrix([[2, 2, 2, 2], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result,
                  [[4, 4, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #13
0
def test_move_up_first_row():
    initial_state = Board.from_matrix([[2, 4, 8, 16], [0, 0, 0, 0],
                                       [0, 0, 0, 0], [0, 0, 0, 0]])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result,
                  [[2, 4, 8, 16], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
Beispiel #14
0
def test_move_right_multiple_columns():
    initial_state = Board.from_matrix([[0, 0, 0, 0], [0, 0, 8, 8],
                                       [0, 0, 0, 2], [0, 0, 0, 4]])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result,
                  [[0, 0, 0, 0], [0, 0, 0, 16], [0, 0, 0, 2], [0, 0, 0, 4]])
Beispiel #15
0
def test_move_left_last_column():
    initial_state = Board.from_matrix([[0, 0, 0, 2], [0, 0, 0, 4],
                                       [0, 0, 0, 8], [0, 0, 0, 16]])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result,
                  [[2, 0, 0, 0], [4, 0, 0, 0], [8, 0, 0, 0], [16, 0, 0, 0]])
def test_move_left_multiple_columns():
    initial_state = Board.from_matrix([
        [ 0, 0, 0, 0 ],
        [ 8, 8, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 4, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result, [
        [  0, 0, 0, 0 ],
        [ 16, 0, 0, 0 ],
        [  2, 0, 0, 0 ],
        [  4, 0, 0, 0 ] ])
def test_move_right_first_equal_with_follower():
    initial_state = Board.from_matrix([
        [ 0, 2, 2, 2 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result, [
        [ 0, 0, 2, 4 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_up_double_equal():
    initial_state = Board.from_matrix([
        [ 2, 0, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 2, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result, [
        [ 4, 0, 0, 0 ],
        [ 4, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_up_first_equal_with_follower():
    initial_state = Board.from_matrix([
        [ 2, 0, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result, [
        [ 4, 0, 0, 0 ],
        [ 2, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_right_multiple_opposite():
    initial_state = Board.from_matrix([
        [  2, 0, 0, 0 ],
        [  4, 0, 0, 0 ],
        [  8, 0, 0, 0 ],
        [ 16, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result, [
        [ 0, 0, 0,  2 ],
        [ 0, 0, 0,  4 ],
        [ 0, 0, 0,  8 ],
        [ 0, 0, 0, 16 ] ])
def test_move_right_multiple_columns():
    initial_state = Board.from_matrix([
        [ 0, 0, 0, 0 ],
        [ 0, 0, 8, 8 ],
        [ 0, 0, 0, 2 ],
        [ 0, 0, 0, 4 ] ])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result, [
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0, 16 ],
        [ 0, 0, 0,  2 ],
        [ 0, 0, 0,  4 ] ])
def test_move_right_double_different_equal():
    initial_state = Board.from_matrix([
        [ 4, 4, 2, 2 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result, [
        [ 0, 0, 8, 4 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_right_middle_equal():
    initial_state = Board.from_matrix([
        [ 0, 2, 2, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_right).to_matrix()
    assert_equals(result, [
        [ 0, 0, 0, 4 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_left_last_column():
    initial_state = Board.from_matrix([
        [ 0, 0, 0,  2 ],
        [ 0, 0, 0,  4 ],
        [ 0, 0, 0,  8 ],
        [ 0, 0, 0, 16 ] ])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result, [
        [  2, 0, 0, 0 ],
        [  4, 0, 0, 0 ],
        [  8, 0, 0, 0 ],
        [ 16, 0, 0, 0 ] ])
def test_move_up_last_row():
    initial_state = Board.from_matrix([
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 2, 4, 8, 16 ] ])

    result = initial_state.move(Action.move_up).to_matrix()
    assert_equals(result, [
        [ 2, 4, 8, 16 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ] ])
def test_move_down_multiple_columns():
    initial_state = Board.from_matrix([
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 8, 0, 0 ],
        [ 0, 8, 2, 4 ] ])

    result = initial_state.move(Action.move_down).to_matrix()
    assert_equals(result, [
        [ 0,  0, 0, 0 ],
        [ 0,  0, 0, 0 ],
        [ 0,  0, 0, 0 ],
        [ 0, 16, 2, 4 ] ])
def test_move_left_first_equal():
    initial_state = Board.from_matrix([
        [ 2, 2, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_left).to_matrix()
    assert_equals(result, [
        [ 4, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_down_empty():
    initial_state = Board.from_matrix([
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])

    result = initial_state.move(Action.move_down).to_matrix()
    assert_equals(result, [
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ],
        [ 0, 0, 0, 0 ] ])
def test_move_down_multiple_opposite():
    initial_state = Board.from_matrix([
        [ 2, 4, 8, 16 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ] ])

    result = initial_state.move(Action.move_down).to_matrix()
    assert_equals(result, [
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 0, 0, 0,  0 ],
        [ 2, 4, 8, 16 ] ])