| 178 | self.getBishopMoves(r, c, moves) |
| 179 | |
| 180 | def getKingMoves(self, r,c,moves): |
| 181 | kingMoves = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1,1) ) |
| 182 | allyColor = "w" if self.whiteToMove else "b" |
| 183 | for i in range(8): |
| 184 | endRow = r + kingMoves[i][0] |
| 185 | endCol = c + kingMoves[i][1] |
| 186 | if 0 <= endRow < 8 and 0 <= endCol < 8: |
| 187 | endPiece = self.board[endRow][endCol] |
| 188 | if endPiece[0] != allyColor: |
| 189 | moves.append(Move((r,c), (endRow, endCol), self.board)) |
| 190 | class Move(): |
| 191 | |
| 192 | ranksToRow = {"1": 7, "2": 6, "3": 5, "4": 4, |