Created
August 29, 2023 10:22
-
-
Save masouduut94/f576396f3b0aefceb9673ae5124cedbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def would_lose(self, cell: tuple, color: int) -> bool: | |
""" | |
Return True is the move indicated by cell and color would lose the game, | |
False otherwise. | |
""" | |
connect1 = False | |
connect2 = False | |
if color == GameMeta.PLAYERS['black']: | |
if cell[1] == 0: | |
connect1 = True | |
elif cell[1] == self.size - 1: | |
connect2 = True | |
for n in self.neighbors(cell): | |
if self.black_groups.connected(GameMeta.EDGE1, n): | |
connect1 = True | |
elif self.black_groups.connected(GameMeta.EDGE2, n): | |
connect2 = True | |
elif color == GameMeta.PLAYERS['white']: | |
if cell[0] == 0: | |
connect1 = True | |
elif cell[0] == self.size - 1: | |
connect2 = True | |
for n in self.neighbors(cell): | |
if self.white_groups.connected(GameMeta.EDGE1, n): | |
connect1 = True | |
elif self.white_groups.connected(GameMeta.EDGE2, n): | |
connect2 = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment