Example #1
0
 def test_white_bishop_attack(self):
     b = Board("rnbqkbnr", #8
               ".ppp.ppp", #7
               "........", #6
               "........", #5
               ".p......", #4
               "BP......", #3
               "PbPPPPPP", #2
               "RN.QKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a3')
     self.assertEqual(moves, {'b2', 'b4'})
Example #2
0
 def test_black_knight_attack(self):
     b = Board("r.bqkbnr", #8
               "pppppppp", #7
               "..n.....", #6
               "P...P...", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('c6')
     self.assertEqual(moves, {'a5', 'b4', 'b8', 'd4', 'e5'})
Example #3
0
 def test_white_bishop(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "BP......", #3
               "P.PPPPPP", #2
               "RN.QKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a3')
     self.assertEqual(moves, {'b2', 'b4', 'c1', 'c5', 'd6', 'e7'})
Example #4
0
 def test_black_knight_start(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('b8')
     self.assertEqual(moves, {'a6', 'c6'})
Example #5
0
 def test_white_knight_attack(self):
     b = Board("rnbqkbnr", #8
               ".ppp.ppp", #7
               "........", #6
               "........", #5
               "p...p...", #4
               "..N.....", #3
               "PPPPPPPP", #2
               "R.BQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('c3')
     self.assertEqual(moves, {'a4', 'b1', 'b5', 'd5', 'e4'})
Example #6
0
 def test_black_pawn_attack_starting(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "PPP.....", #6
               "........", #5
               "........", #4
               "........", #3
               "...PPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('b7')
     self.assertEqual(moves, {'a6', 'c6'})
Example #7
0
 def test_black_bishop_attack(self):
     b = Board("rn.qkbnr", #8
               "pBpppppp", #7
               "bp......", #6
               ".P......", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a6')
     self.assertEqual(moves, {'b5', 'b7'})
Example #8
0
 def test_white_rook_attack(self):
     b = Board("rnbqkbnr", #8
               "p.pp..pp", #7
               "........", #6
               ".p.R.p..", #5
               "P.......", #4
               "...b....", #3
               ".PPPPPPP", #2
               ".NBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('d5')
     self.assertEqual(moves, {'b5', 'c5', 'd3', 'd4', 'd6', 'd7', 'e5', 'f5'})
Example #9
0
 def test_white_pawn_attack(self):
     b = Board("rnbqkbnr", #8
               ".p.ppppp", #7
               "........", #6
               "........", #5
               "p.p.....", #4
               ".P......", #3
               "P.PPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('b3')
     self.assertEqual(moves, {'a4', 'b4', 'c4'})
Example #10
0
 def test_white_pawn_starting(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('e2')
     self.assertEqual(moves, {'e3', 'e4'})
Example #11
0
 def test_white_pawn_attack_starting(self):
     b = Board("rnbqkbnr", #8
               "...ppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "ppp.....", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('b2')
     self.assertEqual(moves, {'a3', 'c3'})
Example #12
0
 def test_black_queen_start(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('d8')
     self.assertEqual(moves, set())
Example #13
0
 def test_king_that_cannot_move(self):
    b = Board("rnbqkbnr", #8
              "pppppppp", #7
              "........", #6
              "........", #5
              "........", #4
              "........", #3
              "PPPPPPPP", #2
              "RNBQKBNR", #1
              #abcdefgh
              )
    moves = b.valid_moves('e1')
    self.assertEqual(moves, set())
Example #14
0
 def test_black_pawn_attack(self):
     b = Board("rnbqkbnr", #8
               "p.pppppp", #7
               ".p......", #6
               "P.P.....", #5
               "........", #4
               "........", #3
               ".P.PPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('b6')
     self.assertEqual(moves, {'a5', 'b5', 'c5'})
Example #15
0
 def test_white_rook_start(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a1')
     self.assertEqual(moves, set())
Example #16
0
 def test_king_taking_a_piece(self):
     b = Board("rnbqkbnr", #8
              "pppppppp", #7
              "....K...", #6
              "........", #5
              "........", #4
              "........", #3
              "PPPPPPPP", #2
              "RNBQ.BNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('e6')
     self.assertEqual(moves, {'d5', 'd6', 'd7', 'e5',
                             'e7', 'f5', 'f6', 'f7'})
Example #17
0
 def test_black_rook_attack(self):
     b = Board(".nbqkbnr", #8
               ".ppppppp", #7
               "........", #6
               "pP.r.P..", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('d5')
     self.assertEqual(moves, {'b5', 'c5', 'd2', 'd3',
                              'd4', 'd6', 'e5', 'f5'})
Example #18
0
 def test_black_rook(self):
     b = Board(".nbqkbnr", #8
               ".ppppppp", #7
               "r.......", #6
               "........", #5
               "p.......", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a6')
     self.assertEqual(moves, {'a5', 'a7', 'a8', 'b6', 'c6',
                              'd6', 'e6', 'f6', 'g6', 'h6'})
Example #19
0
 def test_white_rook(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "P.......", #5
               "........", #4
               "R.......", #3
               ".PPPPPPP", #2
               ".NBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a3')
     self.assertEqual(moves, {'a1', 'a2', 'a4', 'b3', 'c3',
                              'd3', 'e3', 'f3', 'g3', 'h3'})
Example #20
0
 def test_black_queen(self):
     b = Board("rnb.kbnr", #8
               "pp.ppppp", #7
               "........", #6
               "q.p.....", #5
               "........", #4
               "........", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('a5')
     self.assertEqual(moves, {'a2', 'a3', 'a4', 'a6', 'b4',
                              'b5', 'b6', 'c3', 'c7', 'd2',
                              'd8'})
Example #21
0
 def test_white_queen_attack(self):
     b = Board("r..qk.nr", #8
               "p.....pp", #7
               "..npb...", #6
               ".p.Q.p..", #5
               "..p.p...", #4
               "...b....", #3
               "PPPPPPPP", #2
               "RNBQKBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('d5')
     self.assertEqual(moves, {'b5', 'c4', 'c5', 'c6', 'd3',
                              'd4', 'd6', 'e4', 'e5', 'e6',
                              'f5'})
Example #22
0
 def test_white_queen(self):
     b = Board("rnbqkbnr", #8
               "pppppppp", #7
               "........", #6
               "........", #5
               "....P.Q.", #4
               "........", #3
               "PPPP.PPP", #2
               "RNB.KBNR", #1
               #abcdefgh
               )
     moves = b.valid_moves('g4')
     self.assertEqual(moves, {'d1', 'd7', 'e2', 'e6', 'f3',
                              'f4', 'f5', 'g3', 'g5', 'g6',
                              'g7', 'h3', 'h4', 'h5'})