MCPcopy
hub / github.com/ndleah/python-mini-project / getValidMoves

Method getValidMoves

Chess_Game/ChessEngine.py:50–68  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers 1

mainFunction · 0.95

Calls 5

getAllPossibleMovesMethod · 0.95
makeMoveMethod · 0.95
inCheckMethod · 0.95
undoMoveMethod · 0.95
removeMethod · 0.80

Tested by

no test coverage detected