(self)
| 48 | All move considering checks |
| 49 | """ |
| 50 | def getValidMoves(self): |
| 51 | moves = self.getAllPossibleMoves() |
| 52 | for i in range(len(moves)-1, -1, -1): |
| 53 | self.makeMove(moves[i]) |
| 54 | self.whiteToMove = not self.whiteToMove |
| 55 | if self.inCheck(): |
| 56 | moves.remove(moves[i]) |
| 57 | self.whiteToMove = not self.whiteToMove |
| 58 | self.undoMove() |
| 59 | if len(moves) == 0: |
| 60 | if self.inCheck(): |
| 61 | self.checkMate = True |
| 62 | else: |
| 63 | self.staleMate = True |
| 64 | else: |
| 65 | self.checkMate = False |
| 66 | self.staleMate = False |
| 67 | |
| 68 | return moves |
| 69 | |
| 70 | def inCheck(self): |
| 71 | if self.whiteToMove: |