From bc681a68c9c812a2ab3f56d5ea1eb9292c7ee607 Mon Sep 17 00:00:00 2001 From: Rune Daugaard Harlyk Date: Mon, 8 Jan 2024 12:48:55 +0100 Subject: [PATCH] Adds test for the genetation --- test/test_tetris.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/test_tetris.py diff --git a/test/test_tetris.py b/test/test_tetris.py new file mode 100644 index 0000000..2922992 --- /dev/null +++ b/test/test_tetris.py @@ -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()