From 740de07ac8bd829559dffe5fc27dae4464660eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Thu, 15 Feb 2018 13:18:54 +0100 Subject: [PATCH] calculate_legal_states seem to work --- test.py | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) 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 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 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()