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

Method getKingMoves

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

Source from the content-addressed store, hash-verified

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))
190class Move():
191
192 ranksToRow = {"1": 7, "2": 6, "3": 5, "4": 4,

Callers

nothing calls this directly

Calls 1

MoveClass · 0.85

Tested by

no test coverage detected