示例#1
0
    def can_move_vertically_or_horizontally(self, source, destination):
        horizontal = x.index(source[0]) == x.index(
            destination[0]) and y.index(source[1]) != y.index(destination[1])
        vertical = x.index(source[0]) != x.index(destination[0]) and y.index(
            source[1]) == y.index(destination[1])

        return horizontal or vertical
示例#2
0
    def can_move(self, source, destination):
        x_distance = abs(x.index(source[0]) - x.index(destination[0]))
        y_distance = abs(y.index(source[1]) - y.index(destination[1]))

        return x_distance in [0, 1] and y_distance in [
            0, 1
        ] and x_distance + y_distance != 0
示例#3
0
    def can_move(self, _from, to):
        self.moved = True
        x_distance = abs(x.index(_from[0]) - x.index(to[0]))
        y_distance = abs(y.index(_from[1]) - y.index(to[1]))

        return bool(x_distance in [0, 1] and y_distance in [0, 1]
                    and x_distance + y_distance != 0)
示例#4
0
    def can_move(self, _from, to):
        self.moved = True
        x_distance = abs(x.index(_from[0]) - x.index(to[0]))
        y_distance = abs(y.index(_from[1]) - y.index(to[1]))

        return x_distance in [1, 2] and y_distance in [
            1, 2
        ] and x_distance != y_distance
示例#5
0
    def can_move(self, _from, to):
        self.moved = True
        if (self.color == 'white' and x.index(_from[0]) == x.index(to[0])
                and y.index(to[1]) - y.index(_from[1]) == 1):
            return True

        return (self.color == 'black' and x.index(_from[0]) == x.index(to[0])
                and y.index(to[1]) - y.index(_from[1]) == -1)
示例#6
0
    def can_move(self, _from, to):
        self.moved = True
        horizontal = x.index(_from[0]) == x.index(
            to[0]) and y.index(_from[1]) != y.index(to[1])
        vertical = x.index(_from[0]) != x.index(to[0]) and y.index(
            _from[1]) == y.index(to[1])

        return bool(horizontal or vertical)
示例#7
0
    def can_move(self, source, destination):
        if self.color == 'white' and x.index(source[0]) == x.index(destination[0]):
            ordinary_move = y.index(destination[1]) - y.index(source[1]) == 1
            two_square_move = not self.moved and y.index(destination[1]) - y.index(source[1]) == 2
            return ordinary_move or two_square_move

        if self.color == 'black' and x.index(source[0]) == x.index(destination[0]):
            ordinary_move = y.index(destination[1]) - y.index(source[1]) == -1
            two_square_move = not self.moved and y.index(destination[1]) - y.index(source[1]) == -2
            return ordinary_move or two_square_move
        return False
示例#8
0
    def can_move(self, source, destination):
        if self.color == 'white' and x.index(source[0]) == x.index(
                destination[0]):
            ordinary_move = y.index(destination[1]) - y.index(source[1]) == 1
            two_square_move = not self.moved and y.index(
                destination[1]) - y.index(source[1]) == 2
            return ordinary_move or two_square_move

        if self.color == 'black' and x.index(source[0]) == x.index(
                destination[0]):
            ordinary_move = y.index(destination[1]) - y.index(source[1]) == -1
            two_square_move = not self.moved and y.index(
                destination[1]) - y.index(source[1]) == -2
            return ordinary_move or two_square_move
        return False
示例#9
0
    def can_move(self, _from, to):
        self.moved = True
        # move as a Rook {{
        horizontal = x.index(_from[0]) == x.index(
            to[0]) and y.index(_from[1]) != y.index(to[1])
        vertical = x.index(_from[0]) != x.index(to[0]) and y.index(
            _from[1]) == y.index(to[1])

        if horizontal or vertical:
            return True
        # }}

        # move as a Bishop {{
        return abs(x.index(_from[0]) -
                   x.index(to[0])) == abs(y.index(to[1]) - y.index(_from[1]))
示例#10
0
 def can_move_diagonally(self, source, destination):
     return abs(x.index(source[0]) - x.index(destination[0])) == abs(
         y.index(destination[1]) - y.index(source[1]))
示例#11
0
 def __is_valid_pawn_move(self, _from, to):
     if not self.squares[_from].moved:
         return (x.index(_from[0]) == x.index(to[0]) and
                 abs(y.index(to[1]) - y.index(_from[1])) == 2)
     return False
示例#12
0
 def can_move(self, _from, to):
     self.moved = True
     return abs(x.index(_from[0]) -
                x.index(to[0])) == abs(y.index(to[1]) - y.index(_from[1]))
示例#13
0
 def __is_valid_pawn_move(self, _from, to):
     if not self.squares[_from].moved:
         return (x.index(_from[0]) == x.index(to[0])
                 and abs(y.index(to[1]) - y.index(_from[1])) == 2)
     return False
示例#14
0
    def can_move(self, source, destination):
        x_distance = abs(x.index(source[0]) - x.index(destination[0]))
        y_distance = abs(y.index(source[1]) - y.index(destination[1]))

        return x_distance in [1, 2] and y_distance in [1, 2] and x_distance != y_distance
示例#15
0
    def can_move_vertically_or_horizontally(self, source, destination):
        horizontal = x.index(source[0]) == x.index(destination[0]) and y.index(source[1]) != y.index(destination[1])
        vertical = x.index(source[0]) != x.index(destination[0]) and y.index(source[1]) == y.index(destination[1])

        return horizontal or vertical
示例#16
0
 def can_move_diagonally(self, source, destination):
     return abs(x.index(source[0]) - x.index(destination[0])) == abs(y.index(destination[1]) - y.index(source[1]))