Esempio n. 1
0
 def test_moves_in_a_new_game(self):
     board = Board(True)
     expected_moves_white = set([
         ((0, 1), (0, 2)), ((0, 1), (0, 3)),
         ((1, 1), (1, 2)), ((1, 1), (1, 3)),
         ((2, 1), (2, 2)), ((2, 1), (2, 3)),
         ((3, 1), (3, 2)), ((3, 1), (3, 3)),
         ((4, 1), (4, 2)), ((4, 1), (4, 3)),
         ((5, 1), (5, 2)), ((5, 1), (5, 3)),
         ((6, 1), (6, 2)), ((6, 1), (6, 3)),
         ((7, 1), (7, 2)), ((7, 1), (7, 3)),
         ((1, 0), (0, 2)), ((1, 0), (2, 2)),
         ((6, 0), (5, 2)), ((6, 0), (7, 2)),
     ])
     expected_moves_black = set([
         ((0, 6), (0, 5)), ((0, 6), (0, 4)),
         ((1, 6), (1, 5)), ((1, 6), (1, 4)),
         ((2, 6), (2, 5)), ((2, 6), (2, 4)),
         ((3, 6), (3, 5)), ((3, 6), (3, 4)),
         ((4, 6), (4, 5)), ((4, 6), (4, 4)),
         ((5, 6), (5, 5)), ((5, 6), (5, 4)),
         ((6, 6), (6, 5)), ((6, 6), (6, 4)),
         ((7, 6), (7, 5)), ((7, 6), (7, 4)),
         ((1, 7), (0, 5)), ((1, 7), (2, 5)),
         ((6, 7), (5, 5)), ((6, 7), (7, 5)),
     ])
     self.assertEqual(tuples(board.possible_moves(WHITE)),
                      expected_moves_white)
     self.assertEqual(tuples(board.possible_moves(BLACK)),
                      expected_moves_black)
Esempio n. 2
0
 def test_moves_that_keeps_check_are_not_allowed(self):
     board = Board(False)
     board.load_fen("8/8/8/8/8/8/4P3/r3K3 w kQkq - 0 1")
     expected_moves_white = set([
         ((4, 0), (3, 1)),
         ((4, 0), (5, 1)),
     ])
     self.assertEqual(tuples(board.possible_moves(WHITE)),
                      expected_moves_white)
Esempio n. 3
0
 def test_moves_in_a_board_with_just_a_knight(self):
     board = Board(False)
     board.load_fen("8/8/8/4N3/8/8/8/8 w kQkq - 0 1")
     expected_moves_white = set([
         ((4, 4), (3, 2)),
         ((4, 4), (5, 2)),
         ((4, 4), (6, 3)),
         ((4, 4), (6, 5)),
         ((4, 4), (5, 6)),
         ((4, 4), (3, 6)),
         ((4, 4), (2, 5)),
         ((4, 4), (2, 3)),
     ])
     expected_moves_black = set()
     self.assertEqual(tuples(board.possible_moves(WHITE)),
                      expected_moves_white)
     self.assertEqual(tuples(board.possible_moves(BLACK)),
                      expected_moves_black)
Esempio n. 4
0
    def test_moves_that_allows_check_are_not_allowed(self):
        board = Board(False)
        board.load_fen("8/8/8/8/7b/8/5P2/4K3 w - - 0 1")
        expected_moves_white = set([
            ((4, 0), (3, 0)),
            ((4, 0), (3, 1)),
            ((4, 0), (5, 0)),
            ((4, 0), (4, 1)),

        ])
        self.assertEqual(tuples(board.possible_moves(WHITE)),
                         expected_moves_white)