Ejemplo n.º 1
0
    def setup_initial_pieces(self):
        for [row, colour] in [[0, "BLACK"], [7, "WHITE"]]:
            self.board[row][0] = pcs.Rook(colour)
            self.board[row][1] = pcs.Knight(colour)
            self.board[row][2] = pcs.Bishop(colour)
            self.board[row][5] = pcs.Bishop(colour)
            self.board[row][6] = pcs.Knight(colour)
            self.board[row][7] = pcs.Rook(colour)
            for column in range(8):
                if colour == "BLACK":
                    self.board[row + 1][column] = pcs.Pawn(colour)
                else:
                    self.board[row - 1][column] = pcs.Pawn(colour)
            #temp
            self.board[row][0].update_role(roles.BasicRole())
            self.board[row][1].update_role(roles.BasicRole())
            self.board[row][2].update_role(roles.BasicRole())
            self.board[row][5].update_role(roles.BasicRole())
            self.board[row][6].update_role(roles.BasicRole())
            self.board[row][7].update_role(roles.BasicRole())

        self.board[0][3] = pcs.Queen("BLACK")
        self.board[0][4] = pcs.King("BLACK")
        self.board[7][3] = pcs.King("WHITE")
        self.board[7][4] = pcs.Queen("WHITE")

        #temp
        self.board[0][3].update_role(roles.BasicRole())
        self.board[0][4].update_role(roles.BasicRole())
        self.board[7][3].update_role(roles.BasicRole())
        self.board[7][4].update_role(roles.BasicRole())
Ejemplo n.º 2
0
    def __init__(self, grid, screen):
        # White
        grid[0][0] = Pieces.Rook("White", 0, 0, screen)
        grid[0][7] = Pieces.Rook("White", 0, 7, screen)

        grid[0][1] = Pieces.Knight("White", 0, 1, screen)
        grid[0][6] = Pieces.Knight("White", 0, 6, screen)

        grid[0][2] = Pieces.Bishop("White", 0, 2, screen)
        grid[0][5] = Pieces.Bishop("White", 0, 5, screen)

        grid[0][4] = Pieces.Queen("White", 0, 4, screen)
        grid[0][3] = Pieces.King("White", 0, 3, screen)
        for x in range(8):
            grid[1][x] = Pieces.Pawn("White", 1, x, screen)

        # Black changes in some comments
        grid[7][0] = Pieces.Rook("Black", 7, 0, screen)
        grid[7][7] = Pieces.Rook("Black", 7, 7, screen)

        grid[7][1] = Pieces.Knight("Black", 7, 1, screen)
        grid[7][6] = Pieces.Knight("Black", 7, 6, screen)

        grid[7][2] = Pieces.Bishop("Black", 7, 2, screen)
        grid[7][5] = Pieces.Bishop("Black", 7, 5, screen)

        grid[7][4] = Pieces.Queen("Black", 7, 4, screen)
        grid[7][3] = Pieces.King("Black", 7, 3, screen)
        for y in range(8):
            grid[6][y] = Pieces.Pawn("Black", 6, y, screen)
        self.grid = grid
        return
Ejemplo n.º 3
0
    def __init__(self, textmode=False):
        self.textmode = textmode
        self.pieces.append(Pieces.Rook(self.BLACK))
        self.pieces.append(Pieces.Knight(self.BLACK))
        self.pieces.append(Pieces.Bishop(self.BLACK))
        self.pieces.append(Pieces.Queen(self.BLACK))
        self.pieces.append(Pieces.King(self.BLACK))
        self.pieces.append(Pieces.Bishop(self.BLACK))
        self.pieces.append(Pieces.Knight(self.BLACK))
        self.pieces.append(Pieces.Rook(self.BLACK))

        for i in range(9, 17):
            self.pieces.append(Pieces.Pawn(self.BLACK))

        for i in range(17, 65 - 16):
            self.pieces.append(None)

        for i in range(65 - 16, 65 - 8):
            self.pieces.append(Pieces.Pawn(self.WHITE))

        self.pieces.append(Pieces.Rook(self.WHITE))
        self.pieces.append(Pieces.Knight(self.WHITE))
        self.pieces.append(Pieces.Bishop(self.WHITE))
        self.pieces.append(Pieces.Queen(self.WHITE))
        self.pieces.append(Pieces.King(self.WHITE))
        self.pieces.append(Pieces.Bishop(self.WHITE))
        self.pieces.append(Pieces.Knight(self.WHITE))
        self.pieces.append(Pieces.Rook(self.WHITE))
Ejemplo n.º 4
0
 def readyToPlay(self):
     board = [
         [
             Pieces.Rook(Color.WHITE, self),
             Pieces.Knight(Color.WHITE, self),
             Pieces.Bishop(Color.WHITE, self),
             Pieces.King(Color.WHITE, self),
             Pieces.Queen(Color.WHITE, self),
             Pieces.Bishop(Color.WHITE, self),
             Pieces.Knight(Color.WHITE, self),
             Pieces.Rook(Color.WHITE, self),
         ],
         [Pieces.Pawn(Color.WHITE, self) for i in range(8)],
         [PieceName.NONE for i in range(8)],
         [PieceName.NONE for i in range(8)],
         [PieceName.NONE for i in range(8)],
         [PieceName.NONE for i in range(8)],
         [Pieces.Pawn(Color.BLACK, self) for i in range(8)],
         [
             Pieces.Rook(Color.BLACK, self),
             Pieces.Knight(Color.BLACK, self),
             Pieces.Bishop(Color.BLACK, self),
             Pieces.King(Color.BLACK, self),
             Pieces.Queen(Color.BLACK, self),
             Pieces.Bishop(Color.BLACK, self),
             Pieces.Knight(Color.BLACK, self),
             Pieces.Rook(Color.BLACK, self),
         ],
     ]
     for i in range(8):
         for j in range(8):
             self.__playboard[i][j].piece_setter(board[i][j])
     return
Ejemplo n.º 5
0
def gen_knights(board: Board, size, i, wd, wh, bd, bh):
    board.white_pieces.add(Pieces.Knight(
        board, board.get_square((i, size.y - 1)), white, wd, wh))
    board.white_pieces.add(Pieces.Knight(board, board.get_square(
        (size.size - i - 1, size.y - 1)), white, wd, wh))

    board.black_pieces.add(Pieces.Knight(
        board, board.get_square((i, 0)), black, bd, bh))
    board.black_pieces.add(Pieces.Knight(
        board, board.get_square((size.size - i - 1, 0)), black, bd, bh))
Ejemplo n.º 6
0
def pawnPromotion(flag, start_row, start_col, end_row, end_col, name_of_piece):
    attacking_list = brd.isAttacked(gc.GAME_COLOR)
    row_of_king, col_of_king = brd.findPieceOfSameColor(gc.GAME_COLOR, "King")
    if (row_of_king, col_of_king) not in attacking_list:
        brd.board[row_of_king][col_of_king].setIncheck(False)

    global pawn_with_enpassant
    color = ""
    if (flag == 0):
        if (gc.GAME_COLOR == "Black"):
            color = "White"
        else:
            color = "Black"
    else:
        color = gc.GAME_COLOR
    pawn_with_enpassant = (-1, -1)
    brd.board[start_row][start_col] = None
    if name_of_piece.lower() == "Queen".lower():
        brd.board[end_row][end_col] = Pieces.Queen(color)

    if name_of_piece.lower() == "Rook".lower():
        brd.board[end_row][end_col] = Pieces.Rook(color)

    if name_of_piece.lower() == "Bishop".lower():
        brd.board[end_row][end_col] = Pieces.Bishop(color)

    if name_of_piece.lower() == "Knight".lower():
        brd.board[end_row][end_col] = Pieces.Knight(color)

    attacking_list = brd.isAttacked(gc.GAME_COLOR)
    row_of_king, col_of_king = brd.findPieceOfSameColor(gc.GAME_COLOR, "King")
    if (row_of_king, col_of_king) not in attacking_list:
        brd.board[row_of_king][col_of_king].setIncheck(False)
 def init_board(self):
     piece_dict = {
         "P":
         lambda row, col, board, color: p.Pawn(row, col, board, color, self.
                                               special_move_mem),
         "N":
         lambda row, col, board, color: p.Knight(row, col, board, color),
         "B":
         lambda row, col, board, color: p.Bishop(row, col, board, color),
         "Q":
         lambda row, col, board, color: p.Queen(row, col, board, color),
         "K":
         lambda row, col, board, color: p.King(row, col, board, color),
         "R":
         lambda row, col, board, color: p.Rook(row, col, board, color),
     }
     for row in range(0, 8):
         for col in range(0, 8):
             piece = self.string_board[row][col]
             if piece != "..":
                 piece_color = piece[0]
                 if piece_color == 'b':
                     piece_color = "black"
                 else:
                     piece_color = "white"
                 piece_type = piece[1]
                 self.string_board[row][col] = piece_dict[piece_type](
                     row, col, self.string_board, piece_color)
                 if piece_color == "black":
                     self.black_playable_pieces.append(
                         self.string_board[row][col])
                 else:
                     self.white_playable_pieces.append(
                         self.string_board[row][col])
     return self.string_board
Ejemplo n.º 8
0
 def __init__(self):
     super(Chess,
           self).__init__(600,
                          600,
                          resizable=False,
                          caption='Chess',
                          config=pyglet.gl.Config(double_buffer=True),
                          vsync=False)
     self.wKing = p.King(4, 0)
     self.bKing = p.King(4, 7, False)
     self.board = [[
         p.Rook(0, 0),
         p.Knight(1, 0),
         p.Bishop(2, 0),
         p.Queen(3, 0), self.wKing,
         p.Bishop(5, 0),
         p.Knight(6, 0),
         p.Rook(7, 0)
     ], [p.Pawn(i, 1) for i in range(8)], [None for i in range(8)],
                   [None for i in range(8)], [None for i in range(8)],
                   [None for i in range(8)],
                   [p.Pawn(i, 6, False) for i in range(8)],
                   [
                       p.Rook(0, 7, False),
                       p.Knight(1, 7, False),
                       p.Bishop(2, 7, False),
                       p.Queen(3, 7, False), self.bKing,
                       p.Bishop(5, 7, False),
                       p.Knight(6, 7, False),
                       p.Rook(7, 7, False)
                   ]]
     self.validsprites = []
     for i in range(8):
         rowsprites = []
         for j in range(8):
             sprite = pyglet.sprite.Sprite(self.validImg, 75 * j, 75 * i)
             sprite.visible = False
             rowsprites.append(sprite)
         self.validsprites.append(rowsprites)
     self.wQueen = pyglet.sprite.Sprite(self.spritesheet[7], 131.25, 225)
     self.wRook = pyglet.sprite.Sprite(self.spritesheet[10], 218.75, 225)
     self.wBishop = pyglet.sprite.Sprite(self.spritesheet[8], 306.25, 225)
     self.wKnight = pyglet.sprite.Sprite(self.spritesheet[9], 393.75, 225)
     self.bQueen = pyglet.sprite.Sprite(self.spritesheet[1], 131.25, 225)
     self.bRook = pyglet.sprite.Sprite(self.spritesheet[4], 218.75, 225)
     self.bBishop = pyglet.sprite.Sprite(self.spritesheet[2], 306.25, 225)
     self.bKnight = pyglet.sprite.Sprite(self.spritesheet[3], 393.75, 225)
Ejemplo n.º 9
0
def init(color):

    #intialization of board based on the color
    if color.lower() == "white":
        board[0][0] = Pieces.Rook("Black")
        board[0][1] = Pieces.Knight("Black")
        board[0][2] = Pieces.Bishop("Black")
        board[0][3] = Pieces.Queen("Black")
        board[0][4] = Pieces.King("Black")
        board[0][5] = Pieces.Bishop("Black")
        board[0][6] = Pieces.Knight("Black")
        board[0][7] = Pieces.Rook("Black")

        for x in range(8):
            board[1][x] = Pieces.Pawn("Black")

        board[7][0] = Pieces.Rook("White")
        board[7][1] = Pieces.Knight("White")
        board[7][2] = Pieces.Bishop("White")
        board[7][3] = Pieces.Queen("White")
        board[7][4] = Pieces.King("White")
        board[7][5] = Pieces.Bishop("White")
        board[7][6] = Pieces.Knight("White")
        board[7][7] = Pieces.Rook("White")

        for x in range(8):
            board[6][x] = Pieces.Pawn("White")

    else:
        board[0][0] = Pieces.Rook("White")
        board[0][1] = Pieces.Knight("White")
        board[0][2] = Pieces.Bishop("White")
        board[0][3] = Pieces.King("White")
        board[0][4] = Pieces.Queen("White")
        board[0][5] = Pieces.Bishop("White")
        board[0][6] = Pieces.Knight("White")
        board[0][7] = Pieces.Rook("White")

        for x in range(8):
            board[1][x] = Pieces.Pawn("White")

        board[7][0] = Pieces.Rook("Black")
        board[7][1] = Pieces.Knight("Black")
        board[7][2] = Pieces.Bishop("Black")
        board[7][3] = Pieces.King("Black")
        board[7][4] = Pieces.Queen("Black")
        board[7][5] = Pieces.Bishop("Black")
        board[7][6] = Pieces.Knight("Black")
        board[7][7] = Pieces.Rook("Black")

        for x in range(8):
            board[6][x] = Pieces.Pawn("Black")
Ejemplo n.º 10
0
	def getValidMoves(self, board, piece, colour, enforceCaptures=True):
		moves = []
		fr = piece
                # First, we get a (strictly optimistic) list of plausible places this piece could move to,
                # ignoring line of sight and promotions.
                # This is faster than checking validity of all possible moves.
                destList = board.pieces[fr[0]*8+fr[1]].getPlausibleMoves(fr)
                for to in destList:
			m = Move.Move(fr, to)
			try:
				self.validate( m, board, colour, enforceCaptures )
				moves.append( m )
			except RulesViolation as e:
				pass
                # Now consider promotion moves
		promotionPieces = [Pieces.Queen(colour), Pieces.Rook(colour), Pieces.Knight(colour), Pieces.Bishop(colour), Pieces.King(colour)]
                if isinstance(board.pieces[fr[0]*8+fr[1]], Pieces.Pawn):
                        row = fr[0]
                        if colour==0 and row==1:
                                for col in [fr[1]-1, fr[1], fr[1]+1]:
                                        to = [0, col]
                                        for pp in promotionPieces:
				                m = Move.PromotionMove(fr, to, pp)
				                try:
				                	self.validate( m, board, colour, enforceCaptures )
				                	moves.append( m )
				                except RulesViolation as e:
				                	pass
                        elif colour==1 and row==6:
                                for col in [fr[1]-1, fr[1], fr[1]+1]:
                                        to = [7, col]
                                        for pp in promotionPieces:
				                m = Move.PromotionMove(fr, to, pp)
				                try:
				                	self.validate( m, board, colour, enforceCaptures )
				                	moves.append( m )
				                except RulesViolation as e:
				                	pass
		return moves
Ejemplo n.º 11
0
 def fromNotation(m, colour):
     try:
         mm = [m[0:2], m[2:4]]  # e.g. e2e4
         fr = [0, 0]
         to = [0, 0]
         conv = dict(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7)
         fr[1] = conv[mm[0][0]]
         fr[0] = 7 - (int(mm[0][1]) - 1)
         to[1] = conv[mm[1][0]]
         to[0] = 7 - (int(mm[1][1]) - 1)
         # Promotion?
         promotionDict = dict(Q=Pieces.Queen(colour),
                              R=Pieces.Rook(colour),
                              N=Pieces.Knight(colour),
                              B=Pieces.Bishop(colour),
                              K=Pieces.King(colour))
         if len(m) > 4:
             return PromotionMove(fr, to, promotionDict[m[4]])
         else:
             return Move(fr, to)
     except Exception as e:
         print e
         raise
Ejemplo n.º 12
0
                P.Move((5,5))
           ]
pawnStartBlackMoves = [
                    P.Move((6,5), P.NON_CAPTURE),
                    P.Move((6,4), P.NON_CAPTURE)
                 ]
pCPBMoves = [
                P.Move((4,2), P.NON_CAPTURE),
                P.Move((3,2), P.EN_PASSENT),
                P.Move((5,2))
           ]


"""------------KNIGHT TESTS----------"""
knightCenter = deepcopy(board)
knightCenter.board[3][3] = P.Knight(0, P.WHITE)
knightCenter.unmoved.remove(0)

knightCenter2 = deepcopy(knightCenter)
knightCenter2.board[2][1] = P.Pawn(1, P.WHITE)
knightCenter2.board[5][4] = P.Knight(2, P.WHITE)
knightCenter2.board[1][2] = P.Queen(3, P.BLACK)
knightCenter2.board[4][1] = P.Bishop(4, P.BLACK)
knightCenter2.unmoved.remove(2)
knightCenter2.unmoved.remove(3)
knightCenter2.unmoved.remove(4)

knightCorner = deepcopy(board)
knightCorner.board[0][7] = P.Knight(0, P.BLACK)
knightCorner.unmoved.remove(0)
Ejemplo n.º 13
0
import pytest
import Board as B
import Pieces as P
import Logic
from DecisionTree import aiSearch, endStateCheck, Node

stalemate = B.Board(True)

stalemate.board[3][3] = P.King(stalemate.whiteKingId, P.WHITE)
stalemate.board[0][4] = P.Rook(100, P.BLACK)
stalemate.board[2][0] = P.Queen(101, P.BLACK)
stalemate.board[5][1] = P.Knight(102, P.BLACK)
stalemate.board[7][2] = P.Rook(103, P.BLACK)
stalemate.board[7][7] = P.King(stalemate.blackKingId, P.BLACK)
stalemate.unmoved = []
stalemate.initializePosVals()

unknownError = B.Board()
unknownError = Logic.move_piece(unknownError, 4, 1,
                                P.Move((4, 3), P.NON_CAPTURE))
unknownError = Logic.move_piece(unknownError, 6, 6,
                                P.Move((6, 4), P.NON_CAPTURE))
unknownError = Logic.move_piece(unknownError, 3, 0, P.Move((5, 2)))
unknownError = Logic.move_piece(unknownError, 5, 7, P.Move((6, 6)))
unknownError = Logic.move_piece(unknownError, 5, 0, P.Move((2, 3)))
unknownError = Logic.move_piece(unknownError, 0, 6,
                                P.Move((0, 4), P.NON_CAPTURE))
unknownError = Logic.move_piece(unknownError, 5, 2, P.Move((5, 6)))
unknownError.initializePosVals()

crash = B.Board(True)
Ejemplo n.º 14
0
import Pieces as P

W_ROOKS = [P.Rook(0, P.WHITE), P.Rook(5, P.WHITE)]
W_KNIGHTS = [P.Knight(1, P.WHITE), P.Knight(6, P.WHITE)]
W_BISHOPS = [P.Bishop(2, P.WHITE), P.Bishop(7, P.WHITE)]
W_QUEEN = P.Queen(3, P.WHITE)
W_KING = P.King(4, P.WHITE)
W_PAWNS = []

B_ROOKS = [P.Rook(8, P.BLACK), P.Rook(13, P.BLACK)]
B_KNIGHTS = [P.Knight(9, P.BLACK), P.Knight(14, P.BLACK)]
B_BISHOPS = [P.Bishop(10, P.BLACK), P.Bishop(15, P.BLACK)]
B_QUEEN = P.Queen(11, P.BLACK)
B_KING = P.King(12, P.BLACK)
B_PAWNS = []

EMPTY = P.Empty()

for i in range(0, 8):
    W_PAWNS.append(P.Pawn(16 + i, P.WHITE))
    B_PAWNS.append(P.Pawn(24 + i, P.BLACK))


class Board():
    def __init__(self, blank=False):
        self.board = [
        ]  # The game's current state, represented as a 2d array of Piece and Empty objects
        self.unmoved = list(range(
            0, 32))  # The ids of all pieces that haven't moved
        self.whiteChecked = False  # True when white's king is in check
        self.blackChecked = False  # True when black's king is in check
Ejemplo n.º 15
0
 def on_mouse_press(self, x, y, button, modifiers):
     if self.promotion:
         if button == mouse.LEFT:
             if 225 < y < 300:
                 if 131.25 < x < 206.25:
                     self.board[self.promoPawn[0]][
                         self.promoPawn[1]] = p.Queen(
                             self.promoPawn[1], self.promoPawn[0],
                             not self.move)
                 elif 218.75 < x < 293.75:
                     self.board[self.promoPawn[0]][
                         self.promoPawn[1]] = p.Rook(
                             self.promoPawn[1], self.promoPawn[0],
                             not self.move)
                 elif 306.25 < x < 381.25:
                     self.board[self.promoPawn[0]][
                         self.promoPawn[1]] = p.Bishop(
                             self.promoPawn[1], self.promoPawn[0],
                             not self.move)
                 elif 393.75 < x < 468.75:
                     self.board[self.promoPawn[0]][
                         self.promoPawn[1]] = p.Knight(
                             self.promoPawn[1], self.promoPawn[0],
                             not self.move)
             self.promoPawn = (-1, -1)
             self.promotion = False
             if not self.move:
                 if self.bKing.NoValidMoves(
                         self.board) and not self.bKing.InCheck(self.board):
                     print('Stalemate!')
                 if self.bKing.InCheck(self.board):
                     self.bKing.danger.visible = True
                     if self.bKing.NoValidMoves(self.board):
                         print("Checkmate! White wins.")
                 if self.wKing.danger.visible:
                     if not self.wKing.InCheck(self.board):
                         self.wKing.danger.visible = False
             else:
                 if self.wKing.NoValidMoves(
                         self.board) and not self.wKing.InCheck(self.board):
                     print('Stalemate!')
                 if self.wKing.InCheck(self.board):
                     self.wKing.danger.visible = True
                     if self.wKing.NoValidMoves(self.board):
                         print("Checkmate! Black wins.")
                 if self.bKing.danger.visible:
                     if not self.bKing.InCheck(self.board):
                         self.bKing.danger.visible = False
     else:
         if button == mouse.LEFT:
             boardX = x // 75
             boardY = y // 75
             if self.currentPos[0] < 0 and self.currentPos[1] < 0:
                 if self.board[boardY][
                         boardX] is not None and self.move == self.board[
                             boardY][boardX].white:
                     self.currentPos = (boardY, boardX)
                     if self.move:
                         ValidMoves = self.board[boardY][
                             boardX].GetValidMoves(self.board, self.wKing)
                     else:
                         ValidMoves = self.board[boardY][
                             boardX].GetValidMoves(self.board, self.bKing)
                     if len(ValidMoves) == 0:
                         self.currentPos = (-1, -1)
                     else:
                         for move in ValidMoves:
                             self.validsprites[move[0]][
                                 move[1]].visible = True
             elif self.board[boardY][
                     boardX] is not None and self.move == self.board[
                         boardY][boardX].white:
                 for row in self.validsprites:
                     for sprite in row:
                         sprite.visible = False
                 self.currentPos = (boardY, boardX)
                 if self.move:
                     ValidMoves = self.board[boardY][boardX].GetValidMoves(
                         self.board, self.wKing)
                 else:
                     ValidMoves = self.board[boardY][boardX].GetValidMoves(
                         self.board, self.bKing)
                 if len(ValidMoves) == 0:
                     self.currentPos = (-1, -1)
                 else:
                     for move in ValidMoves:
                         self.validsprites[move[0]][move[1]].visible = True
             else:
                 if self.validsprites[boardY][boardX].visible:
                     self.board[boardY][boardX] = self.board[
                         self.currentPos[0]][self.currentPos[1]]
                     self.board[self.currentPos[0]][
                         self.currentPos[1]].ChangeLocation(
                             boardX, boardY, self.board)
                     if type(self.board[self.currentPos[0]][
                             self.currentPos[1]]) is p.Pawn and (
                                 boardY == 0 or boardY == 7):
                         self.promotion = True
                         self.promoPawn = (boardY, boardX)
                     self.board[self.currentPos[0]][
                         self.currentPos[1]] = None
                     self.currentPos = (-1, -1)
                     if self.move:
                         if self.bKing.NoValidMoves(
                                 self.board) and not self.bKing.InCheck(
                                     self.board):
                             print('Stalemate!')
                         if self.bKing.InCheck(self.board):
                             self.bKing.danger.visible = True
                             if self.bKing.NoValidMoves(self.board):
                                 print("Checkmate! White wins.")
                         if self.wKing.danger.visible:
                             if not self.wKing.InCheck(self.board):
                                 self.wKing.danger.visible = False
                     else:
                         if self.wKing.NoValidMoves(
                                 self.board) and not self.wKing.InCheck(
                                     self.board):
                             print('Stalemate!')
                         if self.wKing.InCheck(self.board):
                             self.wKing.danger.visible = True
                             if self.wKing.NoValidMoves(self.board):
                                 print("Checkmate! Black wins.")
                         if self.bKing.danger.visible:
                             if not self.bKing.InCheck(self.board):
                                 self.bKing.danger.visible = False
                     self.move = not self.move
                     for row in self.validsprites:
                         for sprite in row:
                             sprite.visible = False
Ejemplo n.º 16
0
testCase3 = Logic.move_piece(testCase3, 4, 1, P.Move((4, 3), P.NON_CAPTURE))
testCase3 = Logic.move_piece(testCase3, 0, 6, P.Move((0, 4), P.NON_CAPTURE))
testCase3 = Logic.move_piece(testCase3, 3, 0, P.Move((5, 2)))
testCase3 = Logic.move_piece(testCase3, 1, 6, P.Move((1, 4), P.NON_CAPTURE))
testCase3 = Logic.move_piece(testCase3, 5, 0, P.Move((2, 3)))
testCase3 = Logic.move_piece(testCase3, 1, 4, P.Move((1, 3), P.NON_CAPTURE))
testCase3 = Logic.move_piece(testCase3, 5, 2, P.Move((5, 6)))

testCase4 = B.Board(True)
testCase4.board[0][0] = P.King(testCase4.whiteKingId, P.WHITE)
testCase4.board[1][0] = P.Rook(100, P.WHITE)
testCase4.board[2][0] = P.Rook(101, P.WHITE)
testCase4.board[2][1] = P.Queen(102, P.BLACK)
testCase4.board[7][1] = P.Pawn(103, P.WHITE)
testCase4.board[0][2] = P.Pawn(104, P.WHITE)
testCase4.board[1][2] = P.Knight(105, P.BLACK)
testCase4.board[2][3] = P.Knight(106, P.BLACK)
testCase4.board[4][5] = P.Pawn(107, P.BLACK)
testCase4.board[1][6] = P.Pawn(108, P.BLACK)
testCase4.board[6][6] = P.Pawn(109, P.BLACK)
testCase4.board[7][6] = P.Pawn(110, P.BLACK)
testCase4.board[2][7] = P.Bishop(111, P.BLACK)
testCase4.board[3][7] = P.Rook(112, P.BLACK)
testCase4.board[6][7] = P.King(testCase4.blackKingId, P.BLACK)
testCase4.unmoved = [103, 108, 109, 110, 111]
testCase4.initializePosVals()


@pytest.mark.parametrize("b,color,expectedAnswer",
                         [(testCase4, P.WHITE, False),
                          (testCase1, P.WHITE, False),