Skip to content

Commit

Permalink
test: added complex test for transition model
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Prokhorikhin committed Apr 29, 2024
1 parent 43908eb commit e5e4a72
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/game/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,53 @@ def test_transition_model_execution_of_invalid_move_sequence():
for action in actions:
current_board.doAction(action)
assert current_board == target_board

def test_transition_model_result_complex():

innitBoard = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
]

innitBlock1 = Block(3, 0, 0) # I

current_board: Tetris = Tetris(innitBoard, innitBlock1)
target_board: Tetris = copy.deepcopy(current_board)
settup = [Action.ROTATE_CLOCKWISE]
for x in range(3): settup.append(Action.MOVE_RIGHT)
for x in range(18): settup.append(Action.SOFT_DROP)
for x in range(2): settup.append(Action.MOVE_LEFT)
settup.append(Action.HARD_DROP)

for action in settup:
target_board.doAction(action)

# Test if the actions from the transition model result in the target board
actions = transition_model(current_board, target_board)
for action in actions:
current_board.doAction(action)

assert current_board == target_board


0 comments on commit e5e4a72

Please sign in to comment.