示例#1
0
def get_chinese_rule_set():
    """
    https://senseis.xmp.net/?ChineseRules
    """
    return RuleSet(SelfCaptureRule,
                   SuperKoRule,
                   komi=Score(w_score=7.5),
                   name="chinese")
示例#2
0
def get_japanese_rule_set():
    """
    https://senseis.xmp.net/?JapaneseRules
    """
    return RuleSet(SelfCaptureRule,
                   KoRule,
                   komi=Score(w_score=6.5),
                   name="japanese")
示例#3
0
 def score(self):
     black, white = self._score.b_score, self._score.w_score
     if self.territory is not None:
         black += self.territory.num_black_territory
         white += self.territory.num_white_territory
         groups = self.board.endgame_dead_groups
         white += sum(
             len(group) for group in groups if group.color == Color.black)
         black += sum(
             len(group) for group in groups if group.color == Color.white)
     return Score(w_score=white, b_score=black)
示例#4
0
文件: Board.py 项目: levavft/WukongGo
    def _remove_group(self, group):
        score = Score.from_dict(score_dict={
            group.color.other: len(group.stones),
            group.color: 0
        })
        for point in group.stones:
            for neighbor in point.neighbors():
                neighbor_group = self._grid.get(neighbor)
                if neighbor_group is None:
                    continue
                if neighbor_group is not group:
                    self._replace_group(neighbor_group.with_liberty(point))
            self._grid[point] = None

            self._hash ^= zobrist.HASH_CODE[point, group.color]
        return score
示例#5
0
文件: Board.py 项目: levavft/WukongGo
    def place_stone(self, color, point):
        assert self.is_on_grid(point)
        assert self._grid.get(point) is None
        adjacent_same_color = []
        adjacent_opposite_color = []
        liberties = []
        score = Score(0, 0)

        for neighbor in point.neighbors():
            if not self.is_on_grid(neighbor):
                continue
            neighbor_group = self._grid.get(neighbor)
            if neighbor_group is None:
                liberties.append(neighbor)
            elif neighbor_group.color == color:
                if neighbor_group not in adjacent_same_color:
                    adjacent_same_color.append(neighbor_group)
            else:
                if neighbor_group not in adjacent_opposite_color:
                    adjacent_opposite_color.append(neighbor_group)

        new_group = GoGroup(color, [point], liberties)

        for same_color_group in adjacent_same_color:
            new_group = new_group.merged_with(same_color_group)
        for new_group_point in new_group.stones:
            self._grid[new_group_point] = new_group

        self._hash ^= zobrist.HASH_CODE[point, color]

        for other_color_group in adjacent_opposite_color:
            replacement = other_color_group.without_liberty(point)
            if replacement.num_liberties:
                self._replace_group(other_color_group.without_liberty(point))
            else:
                score += self._remove_group(other_color_group)
        return score
示例#6
0
def get_ign_rule_set():
    """
    https://senseis.xmp.net/?IngRules
    """
    return RuleSet(SuperKoRule, komi=Score(w_score=7.5), name="ign")
示例#7
0
def get_ai_rule_set():
    return RuleSet(SelfCaptureRule,
                   SuperKoRule,
                   komi=Score(w_score=7.5),
                   name="ai")