Esempio n. 1
0
def test_spawn_x0_y0():
    actual = spawning.spawn(
        board=make_test_empty_board(),
        get_spawn_location=lambda choices: models.Point(x=0, y=0),
        get_value=lambda: 2)
    expected = [[2, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
    assert actual == expected
Esempio n. 2
0
def test_spawn_avoids_filled_spaces_2():
    board = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 1], [1, 1, 1, 1]]

    def first_index(choices):
        return min(choices, key=lambda choice: choice.x + 4 * choice.y)

    actual = spawning.spawn(board=board,
                            get_spawn_location=first_index,
                            get_value=lambda: 2)
    expected = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 2, 1], [1, 1, 1, 1]]
    assert actual == expected