当前位置: 首页>>代码示例>>Python>>正文


Python go.MISSING_GROUP_ID属性代码示例

本文整理汇总了Python中go.MISSING_GROUP_ID属性的典型用法代码示例。如果您正苦于以下问题:Python go.MISSING_GROUP_ID属性的具体用法?Python go.MISSING_GROUP_ID怎么用?Python go.MISSING_GROUP_ID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在go的用法示例。


在下文中一共展示了go.MISSING_GROUP_ID属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_place_stone_opposite_color

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone_opposite_color(self):
        board = test_utils.load_board('X........' + EMPTY_ROW * 8)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(WHITE, coords.from_kgs('B9'))
        self.assertEqual(len(lib_tracker.groups), 2)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_kgs('A9')], go.MISSING_GROUP_ID)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_kgs('B9')], go.MISSING_GROUP_ID)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs('A9')], 1)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs('B9')], 2)
        black_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
            'A9')]]
        white_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
            'B9')]]
        self.assertEqual(black_group.stones, coords_from_kgs_set('A9'))
        self.assertEqual(black_group.liberties, coords_from_kgs_set('A8'))
        self.assertEqual(black_group.color, BLACK)
        self.assertEqual(white_group.stones, coords_from_kgs_set('B9'))
        self.assertEqual(white_group.liberties, coords_from_kgs_set('C9 B8'))
        self.assertEqual(white_group.color, WHITE) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:23,代码来源:test_go.py

示例2: test_merge_multiple_groups

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_merge_multiple_groups(self):
        board = test_utils.load_board('''
            .X.......
            X.X......
            .X.......
        ''' + EMPTY_ROW * 6)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(BLACK, coords.from_kgs('B8'))
        self.assertEqual(len(lib_tracker.groups), 1)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_kgs('B8')], go.MISSING_GROUP_ID)
        sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
            'B8')]]
        self.assertEqual(sole_group.stones,
                         coords_from_kgs_set('B9 A8 B8 C8 B7'))
        self.assertEqual(sole_group.liberties,
                         coords_from_kgs_set('A9 C9 D8 A7 C7 B6'))
        self.assertEqual(sole_group.color, BLACK)

        liberty_cache = lib_tracker.liberty_cache
        for stone in sole_group.stones:
            self.assertEqual(liberty_cache[stone], 6, str(stone)) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:24,代码来源:test_go.py

示例3: test_place_stone_opposite_color

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone_opposite_color(self):
        board = load_board('X........' + EMPTY_ROW * 8)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(WHITE, pc('B9'))
        self.assertEqual(len(lib_tracker.groups), 2)
        self.assertNotEqual(lib_tracker.group_index[pc('A9')], go.MISSING_GROUP_ID)
        self.assertNotEqual(lib_tracker.group_index[pc('B9')], go.MISSING_GROUP_ID)
        self.assertEqual(lib_tracker.liberty_cache[pc('A9')], 1)
        self.assertEqual(lib_tracker.liberty_cache[pc('B9')], 2)
        black_group = lib_tracker.groups[lib_tracker.group_index[pc('A9')]]
        white_group = lib_tracker.groups[lib_tracker.group_index[pc('B9')]]
        self.assertEqual(black_group.stones, pc_set('A9'))
        self.assertEqual(black_group.liberties, pc_set('A8'))
        self.assertEqual(black_group.color, BLACK)
        self.assertEqual(white_group.stones, pc_set('B9'))
        self.assertEqual(white_group.liberties, pc_set('C9 B8'))
        self.assertEqual(white_group.color, WHITE) 
开发者ID:llSourcell,项目名称:alphago_demo,代码行数:19,代码来源:test_go.py

示例4: test_merge_multiple_groups

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_merge_multiple_groups(self):
        board = load_board('''
            .X.......
            X.X......
            .X.......
        ''' + EMPTY_ROW * 6)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(BLACK, pc('B8'))
        self.assertEqual(len(lib_tracker.groups), 1)
        self.assertNotEqual(lib_tracker.group_index[pc('B8')], go.MISSING_GROUP_ID)
        sole_group = lib_tracker.groups[lib_tracker.group_index[pc('B8')]]
        self.assertEqual(sole_group.stones, pc_set('B9 A8 B8 C8 B7'))
        self.assertEqual(sole_group.liberties, pc_set('A9 C9 D8 A7 C7 B6'))
        self.assertEqual(sole_group.color, BLACK)

        liberty_cache = lib_tracker.liberty_cache
        for stone in sole_group.stones:
            self.assertEqual(liberty_cache[stone], 6, str(stone)) 
开发者ID:llSourcell,项目名称:alphago_demo,代码行数:20,代码来源:test_go.py

示例5: test_place_stone

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone(self):
    board = utils_test.load_board('X........' + EMPTY_ROW * 8)
    lib_tracker = LibertyTracker.from_board(utils_test.BOARD_SIZE, board)
    lib_tracker.add_stone(BLACK, coords.from_kgs(utils_test.BOARD_SIZE, 'B9'))
    self.assertEqual(len(lib_tracker.groups), 1)
    self.assertNotEqual(
        lib_tracker.group_index[coords.from_kgs(
            utils_test.BOARD_SIZE, 'A9')], go.MISSING_GROUP_ID)
    self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs(
        utils_test.BOARD_SIZE, 'A9')], 3)
    self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs(
        utils_test.BOARD_SIZE, 'B9')], 3)
    sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
        utils_test.BOARD_SIZE, 'A9')]]
    self.assertEqual(sole_group.stones, coords_from_kgs_set('A9 B9'))
    self.assertEqual(sole_group.liberties,
                     coords_from_kgs_set('C9 A8 B8'))
    self.assertEqual(sole_group.color, BLACK) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:20,代码来源:go_test.py

示例6: test_place_stone_opposite_color

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone_opposite_color(self):
    board = utils_test.load_board('X........' + EMPTY_ROW * 8)
    lib_tracker = LibertyTracker.from_board(utils_test.BOARD_SIZE, board)
    lib_tracker.add_stone(WHITE, coords.from_kgs(utils_test.BOARD_SIZE, 'B9'))
    self.assertEqual(len(lib_tracker.groups), 2)
    self.assertNotEqual(
        lib_tracker.group_index[coords.from_kgs(
            utils_test.BOARD_SIZE, 'A9')], go.MISSING_GROUP_ID)
    self.assertNotEqual(
        lib_tracker.group_index[coords.from_kgs(
            utils_test.BOARD_SIZE, 'B9')], go.MISSING_GROUP_ID)
    self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs(
        utils_test.BOARD_SIZE, 'A9')], 1)
    self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs(
        utils_test.BOARD_SIZE, 'B9')], 2)
    black_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
        utils_test.BOARD_SIZE, 'A9')]]
    white_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
        utils_test.BOARD_SIZE, 'B9')]]
    self.assertEqual(black_group.stones, coords_from_kgs_set('A9'))
    self.assertEqual(black_group.liberties, coords_from_kgs_set('A8'))
    self.assertEqual(black_group.color, BLACK)
    self.assertEqual(white_group.stones, coords_from_kgs_set('B9'))
    self.assertEqual(white_group.liberties, coords_from_kgs_set('C9 B8'))
    self.assertEqual(white_group.color, WHITE) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:27,代码来源:go_test.py

示例7: test_merge_multiple_groups

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_merge_multiple_groups(self):
    board = utils_test.load_board('''
      .X.......
      X.X......
      .X.......
    ''' + EMPTY_ROW * 6)
    lib_tracker = LibertyTracker.from_board(utils_test.BOARD_SIZE, board)
    lib_tracker.add_stone(BLACK, coords.from_kgs(utils_test.BOARD_SIZE, 'B8'))
    self.assertEqual(len(lib_tracker.groups), 1)
    self.assertNotEqual(
        lib_tracker.group_index[coords.from_kgs(
            utils_test.BOARD_SIZE, 'B8')], go.MISSING_GROUP_ID)
    sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
        utils_test.BOARD_SIZE, 'B8')]]
    self.assertEqual(sole_group.stones,
                     coords_from_kgs_set('B9 A8 B8 C8 B7'))
    self.assertEqual(sole_group.liberties,
                     coords_from_kgs_set('A9 C9 D8 A7 C7 B6'))
    self.assertEqual(sole_group.color, BLACK)

    liberty_cache = lib_tracker.liberty_cache
    for stone in sole_group.stones:
      self.assertEqual(liberty_cache[stone], 6, str(stone)) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:25,代码来源:go_test.py

示例8: test_place_stone_opposite_color

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone_opposite_color(self):
        board = test_utils.load_board('X........' + EMPTY_ROW * 8)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(WHITE, coords.from_gtp('B9'))
        self.assertEqual(len(lib_tracker.groups), 2)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_gtp('A9')], go.MISSING_GROUP_ID)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_gtp('B9')], go.MISSING_GROUP_ID)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_gtp('A9')], 1)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_gtp('B9')], 2)
        black_group = lib_tracker.groups[lib_tracker.group_index[coords.from_gtp(
            'A9')]]
        white_group = lib_tracker.groups[lib_tracker.group_index[coords.from_gtp(
            'B9')]]
        self.assertEqual(black_group.stones, coords_from_gtp_set('A9'))
        self.assertEqual(black_group.liberties, coords_from_gtp_set('A8'))
        self.assertEqual(black_group.color, BLACK)
        self.assertEqual(white_group.stones, coords_from_gtp_set('B9'))
        self.assertEqual(white_group.liberties, coords_from_gtp_set('C9 B8'))
        self.assertEqual(white_group.color, WHITE) 
开发者ID:mlperf,项目名称:training,代码行数:23,代码来源:test_go.py

示例9: test_merge_multiple_groups

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_merge_multiple_groups(self):
        board = test_utils.load_board('''
            .X.......
            X.X......
            .X.......
        ''' + EMPTY_ROW * 6)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(BLACK, coords.from_gtp('B8'))
        self.assertEqual(len(lib_tracker.groups), 1)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_gtp('B8')], go.MISSING_GROUP_ID)
        sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_gtp(
            'B8')]]
        self.assertEqual(sole_group.stones,
                         coords_from_gtp_set('B9 A8 B8 C8 B7'))
        self.assertEqual(sole_group.liberties,
                         coords_from_gtp_set('A9 C9 D8 A7 C7 B6'))
        self.assertEqual(sole_group.color, BLACK)

        liberty_cache = lib_tracker.liberty_cache
        for stone in sole_group.stones:
            self.assertEqual(liberty_cache[stone], 6, str(stone)) 
开发者ID:mlperf,项目名称:training,代码行数:24,代码来源:test_go.py

示例10: test_lib_tracker_init

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_lib_tracker_init(self):
        board = test_utils.load_board('X........' + EMPTY_ROW * 8)

        lib_tracker = LibertyTracker.from_board(board)
        self.assertEqual(len(lib_tracker.groups), 1)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_kgs('A9')], go.MISSING_GROUP_ID)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs('A9')], 2)
        sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
            'A9')]]
        self.assertEqual(sole_group.stones, coords_from_kgs_set('A9'))
        self.assertEqual(sole_group.liberties, coords_from_kgs_set('B9 A8'))
        self.assertEqual(sole_group.color, BLACK) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:15,代码来源:test_go.py

示例11: test_place_stone

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_place_stone(self):
        board = test_utils.load_board('X........' + EMPTY_ROW * 8)
        lib_tracker = LibertyTracker.from_board(board)
        lib_tracker.add_stone(BLACK, coords.from_kgs('B9'))
        self.assertEqual(len(lib_tracker.groups), 1)
        self.assertNotEqual(
            lib_tracker.group_index[coords.from_kgs('A9')], go.MISSING_GROUP_ID)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs('A9')], 3)
        self.assertEqual(lib_tracker.liberty_cache[coords.from_kgs('B9')], 3)
        sole_group = lib_tracker.groups[lib_tracker.group_index[coords.from_kgs(
            'A9')]]
        self.assertEqual(sole_group.stones, coords_from_kgs_set('A9 B9'))
        self.assertEqual(sole_group.liberties,
                         coords_from_kgs_set('C9 A8 B8'))
        self.assertEqual(sole_group.color, BLACK) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:17,代码来源:test_go.py

示例12: test_capture_stone

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def test_capture_stone(self):
        board = test_utils.load_board('''
            .X.......
            XO.......
            .X.......
        ''' + EMPTY_ROW * 6)
        lib_tracker = LibertyTracker.from_board(board)
        captured = lib_tracker.add_stone(BLACK, coords.from_kgs('C8'))
        self.assertEqual(len(lib_tracker.groups), 4)
        self.assertEqual(
            lib_tracker.group_index[coords.from_kgs('B8')], go.MISSING_GROUP_ID)
        self.assertEqual(captured, coords_from_kgs_set('B8')) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:14,代码来源:test_go.py

示例13: assertEqualLibTracker

# 需要导入模块: import go [as 别名]
# 或者: from go import MISSING_GROUP_ID [as 别名]
def assertEqualLibTracker(self, lib_tracker1, lib_tracker2):
        # A lib tracker may have differently numbered groups yet still
        # represent the same set of groups.
        # "Sort" the group_ids to ensure they are the same.
        def find_group_mapping(lib_tracker):
            current_gid = 0
            mapping = {}
            for group_id in lib_tracker.group_index.ravel().tolist():
                if group_id == go.MISSING_GROUP_ID:
                    continue
                if group_id not in mapping:
                    mapping[group_id] = current_gid
                    current_gid += 1
            return mapping

        lt1_mapping = find_group_mapping(lib_tracker1)
        lt2_mapping = find_group_mapping(lib_tracker2)

        remapped_group_index1 = [lt1_mapping.get(
            gid, go.MISSING_GROUP_ID) for gid in lib_tracker1.group_index.ravel().tolist()]
        remapped_group_index2 = [lt2_mapping.get(
            gid, go.MISSING_GROUP_ID) for gid in lib_tracker2.group_index.ravel().tolist()]
        self.assertEqual(remapped_group_index1, remapped_group_index2)

        remapped_groups1 = {lt1_mapping.get(
            gid): group for gid, group in lib_tracker1.groups.items()}
        remapped_groups2 = {lt2_mapping.get(
            gid): group for gid, group in lib_tracker2.groups.items()}
        self.assertEqual(remapped_groups1, remapped_groups2)

        self.assertEqualNPArray(
            lib_tracker1.liberty_cache, lib_tracker2.liberty_cache) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:34,代码来源:test_utils.py


注:本文中的go.MISSING_GROUP_ID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。