當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。