Beispiel #1
0
 def __remove_liberties(self, move):
     """
     Updates the liberties of all opponent groups when a stone is added, 
     removing the corresponding libertie
     """
     for group in self.get_groups_by_color(get_opponent_color(move.color)):
         group.remove_libertie(move.vertex)
Beispiel #2
0
    def __set_winner_if_possible(self, move):

        color = move.color
        
        if Vertex.PASS() == move.vertex:
            if ((color == WHITE_COLOR and self.last_white_move_is_pass) or 
                (color == BLACK_COLOR and self.last_black_move_is_pass)):
                self.winner = get_opponent_color(color)
                self.game_finished = True
        elif not self.__has_liberties(get_opponent_color(color)):
            # capture opponent
            self.winner = color
            self.game_finished = True
        elif not self.__has_liberties(color): 
            # suicide
            self.winner = get_opponent_color(color)
            self.game_finished = True
Beispiel #3
0
 def test_get_opponent_color(self):
     
     self.assertEqual(get_opponent_color(WHITE_COLOR), BLACK_COLOR)
     self.assertEqual(get_opponent_color(BLACK_COLOR), WHITE_COLOR)