calculate_legal_states seem to work

This commit is contained in:
Christoffer Müller Madsen 2018-02-15 13:18:54 +01:00
parent b5007c470a
commit 740de07ac8

119
test.py
View File

@ -272,5 +272,124 @@ class TestLegalMoves(unittest.TestCase):
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, 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