Skip to content

Commit

Permalink
Adds test for the genetation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rune Daugaard Harlyk authored and runeharlyk committed Jan 8, 2024
1 parent a594411 commit bc681a6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_tetris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import unittest
import sys
import os

parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parent_dir)

from environment.tetris import Tetris
env = Tetris(10, 20)

class TestNumberOfActionFunction(unittest.TestCase):
def test_number_actions_with_holding_piece_t_duplicate(self): # Most unique rotations
env.shape = env.SHAPES[0]
env.held_shapes.append(env.SHAPES[0])

actual_actions = env.get_possible_actions()

self.assertEqual(len(actual_actions), 34)

def test_number_actions_with_holding_piece_s_duplicate(self): # Most unique rotations
env.shape = env.SHAPES[1]
env.held_shapes.append(env.SHAPES[1])

actual_actions = env.get_possible_actions()

self.assertEqual(len(actual_actions), 17)

if __name__ == '__main__':
unittest.main()

0 comments on commit bc681a6

Please sign in to comment.