| 55 | return validMoves |
| 56 | |
| 57 | def King(self, x, y, grid): |
| 58 | for i in range(-1, 2): |
| 59 | for j in range(-1, 2): |
| 60 | if i == 0 and j == 0: |
| 61 | continue |
| 62 | self.vMoves.append([x + i, y + j]) |
| 63 | |
| 64 | for i in range(len(self.vMoves)): |
| 65 | if ( |
| 66 | self.vMoves[i][1] >= 0 |
| 67 | and self.vMoves[i][0] >= 0 |
| 68 | and self.vMoves[i][1] < 8 |
| 69 | and self.vMoves[i][0] < 8 |
| 70 | ): |
| 71 | base = grid[self.vMoves[i][0]][self.vMoves[i][1]] |
| 72 | sameColor = None |
| 73 | if base == 0: |
| 74 | sameColor = False |
| 75 | elif self.white: |
| 76 | sameColor = base.isupper() |
| 77 | else: |
| 78 | sameColor = base.islower() |
| 79 | |
| 80 | if not sameColor: |
| 81 | self.vMoves2.append([self.vMoves[i][0], self.vMoves[i][1]]) |
| 82 | |
| 83 | return self.vMoves2 |
| 84 | |
| 85 | def Queen(self, x, y, grid): |
| 86 | r, b = self.Rook(x, y, grid), self.Bishop(x, y, grid) |