diff --git a/test.py b/test.py index c9c40a9..6581eff 100644 --- a/test.py +++ b/test.py @@ -271,6 +271,125 @@ class TestLegalMoves(unittest.TestCase): self.assertEqual(Board.calculate_legal_states(board, -1, (1,1)), { board }) self.assertEqual(Board.calculate_legal_states(board, -1, (3,1)), expected_board_set_3_1) self.assertEqual(Board.calculate_legal_states(board, -1, (3,4)), expected_board_set_3_4) - + + def test_multiple_checkers(self): + board = ( 0, + 0, 0, 1, 0, 0, 1, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ) + expected_board_set_3_5 = { + ( 0, + 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ) + } + self.assertEqual(Board.calculate_legal_states(board, 1, (3,5)), expected_board_set_3_5) + + def test_double_roll(self): + board = ( 0, + 2, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ) + + expected_board_set_1_1 = { + ( 0, + 1, 0, 0, 2, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 2, 0, 0, 1, 0, 0, + 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 0, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 2, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 1, 1, 0, 1, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 1, 0, 1, 1, 0, 1, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 2, 0, 0, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 2, 0, 1, 0, 1, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 1, 1, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 0, 1, 0, 3, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ), + ( 0, + 1, 0, 1, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, + 0 ) + } + + self.assertEqual(Board.calculate_legal_states(board, 1, (1,1)), expected_board_set_1_1) if __name__ == '__main__': unittest.main()