MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / Rook

Method Rook

projects/Chess/main.py:93–127  ·  view source on GitHub ↗
(self, x, y, grid)

Source from the content-addressed store, hash-verified

91 return self.vMoves
92
93 def Rook(self, x, y, grid):
94 for i in range(x + 1, 8):
95 if grid[i][y] == 0:
96 self.vMoves.append([i, y])
97 continue
98 if not self.sameColor(i, y, grid):
99 self.vMoves.append([i, y])
100 break
101 break
102 for i in range(x - 1, -1, -1):
103 if grid[i][y] == 0:
104 self.vMoves.append([i, y])
105 continue
106 if not self.sameColor(i, y, grid):
107 self.vMoves.append([i, y])
108 break
109 break
110 for i in range(y + 1, 8):
111 if grid[x][i] == 0:
112 self.vMoves.append([x, i])
113 continue
114 if not self.sameColor(x, i, grid):
115 self.vMoves.append([x, i])
116 break
117 break
118 for i in range(y - 1, -1, -1):
119 if grid[x][i] == 0:
120 self.vMoves.append([x, i])
121 continue
122 if not self.sameColor(x, i, grid):
123 self.vMoves.append([x, i])
124 break
125 break
126
127 return self.vMoves
128
129 def Bishop(self, x, y, grid):
130 for i in range(1, 8):

Callers 2

generateValidMovesMethod · 0.95
QueenMethod · 0.95

Calls 1

sameColorMethod · 0.95

Tested by

no test coverage detected