Created
February 14, 2018 19:57
-
-
Save uberto/1d51d648d91a895b35fbb279d830c5da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Python | |
def remove_string(self, string): | |
for point in string.stones: | |
# Removing a string can create liberties for other strings. | |
for neighbor in self.neighbor_table[point]: | |
neighbor_string = self._grid.get(neighbor) | |
if neighbor_string is None: | |
continue | |
if neighbor_string is not string: | |
self._replace_string(neighbor_string.with_liberty(point)) | |
self._grid[point] = None | |
# Remove filled point hash code. | |
self._hash ^= zobrist.HASH_CODE[point, string.color] | |
Kotlin | |
fun removeString(string: GoString){ | |
for (point in string.stones){ | |
// Removing a string can create liberties for other strings. | |
for (neighbor: Point in neighbors(point)){ | |
val neighborString = grid[neighbor] ?: continue | |
if (neighborString != string) { | |
updateStringOnGrid(neighborString.addLiberty(point)) | |
} | |
} | |
grid[point] = null | |
// Remove filled point hash code. | |
zHash = zHash.xor(zobristTable.getValue(point)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment