MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / getKnightMoves

Method getKnightMoves

Chess_Game/ChessEngine.py:146–155  ·  view source on GitHub ↗
(self, r,c,moves)

Source from the content-addressed store, hash-verified

144 break
145
146 def getKnightMoves(self, r,c,moves):
147 knightMoves = ((-2, -1), (-2, 1), (-1, -2), (-1, 2), (1, -2), (1, 2), (2, -1), (2,1))
148 allyColor = "w" if self.whiteToMove else "b"
149 for m in knightMoves:
150 endRow = r + m[0]
151 endCol = c + m[1]
152 if 0 <= endRow < 8 and 0 <= endCol < 8:
153 endPiece = self.board[endRow][endCol]
154 if endPiece[0] != allyColor:
155 moves.append(Move((r,c), (endRow, endCol), self.board))
156
157 def getBishopMoves(self, r,c,moves):
158 directions = ((-1, -1), (-1, 1), (1, -1), (1, 1))

Callers

nothing calls this directly

Calls 1

MoveClass · 0.85

Tested by

no test coverage detected