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


Python Table.init_round方法代码示例

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


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

示例1: test_find_dealer_tile_to_discard

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_find_dealer_tile_to_discard(self):
        dealer = 2
        dora = self._string_to_136_tile(honors='3')
        table = Table()
        table.init_round(0, 0, 0, dora, dealer, [])

        tiles = self._string_to_136_array(sou='2234678', pin='34', man='45789')
        table.player.init_hand(tiles)

        table.add_discarded_tile(1, self._string_to_136_tile(man='4'), False)
        table.add_discarded_tile(1, self._string_to_136_tile(man='5'), False)

        table.add_discarded_tile(2, self._string_to_136_tile(man='8'), False)
        table.add_discarded_tile(2, self._string_to_136_tile(man='9'), False)

        table.add_called_riichi(1)
        table.add_called_riichi(2)

        # for this test we don't need temporary_safe_tiles
        table.get_player(1).temporary_safe_tiles = []
        table.get_player(2).temporary_safe_tiles = []

        result = table.player.discard_tile()
        # second player is a dealer, let's fold against him
        self.assertEqual(self._to_string([result]), '9m')

        tiles = self._string_to_136_array(sou='234567', pin='348', man='234', honors='23')
        table.player.init_hand(tiles)

        result = table.player.discard_tile()
        # there is no safe tiles against dealer, so let's fold against other players
        self.assertEqual(table.player.ai.in_defence, True)
        self.assertEqual(self._to_string([result]), '4m')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:35,代码来源:tests_defence.py

示例2: test_set_scores

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_set_scores(self):
        table = Table()
        table.init_round(0, 0, 0, 0, 0, [])
        scores = [230, 110, 55, 405]

        table.set_players_scores(scores)

        self.assertEqual(table.get_player(0).scores, 23000)
        self.assertEqual(table.get_player(1).scores, 11000)
        self.assertEqual(table.get_player(2).scores, 5500)
        self.assertEqual(table.get_player(3).scores, 40500)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:13,代码来源:tests_table.py

示例3: test_is_dora

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_is_dora(self):
        table = Table()
        table.init_round(0, 0, 0, 0, 0, [])

        table.dora_indicators = [self._string_to_136_tile(sou='1')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(sou='2')))

        table.dora_indicators = [self._string_to_136_tile(sou='9')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(sou='1')))

        table.dora_indicators = [self._string_to_136_tile(pin='9')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(pin='1')))

        table.dora_indicators = [self._string_to_136_tile(man='9')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(man='1')))

        table.dora_indicators = [self._string_to_136_tile(man='5')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(man='6')))

        table.dora_indicators = [self._string_to_136_tile(honors='1')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='2')))

        table.dora_indicators = [self._string_to_136_tile(honors='2')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='3')))

        table.dora_indicators = [self._string_to_136_tile(honors='3')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='4')))

        table.dora_indicators = [self._string_to_136_tile(honors='4')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='1')))

        table.dora_indicators = [self._string_to_136_tile(honors='5')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='6')))

        table.dora_indicators = [self._string_to_136_tile(honors='6')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='7')))

        table.dora_indicators = [self._string_to_136_tile(honors='7')]
        self.assertTrue(table.is_dora(self._string_to_136_tile(honors='5')))

        table.dora_indicators = [self._string_to_136_tile(pin='1')]
        self.assertFalse(table.is_dora(self._string_to_136_tile(sou='2')))

        table.has_open_tanyao = True

        # red five man
        self.assertTrue(table.is_dora(FIVE_RED_MAN))

        # red five pin
        self.assertTrue(table.is_dora(FIVE_RED_PIN))

        # red five sou
        self.assertTrue(table.is_dora(FIVE_RED_SOU))
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:55,代码来源:tests_table.py

示例4: test_set_scores_and_uma

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_set_scores_and_uma(self):
        table = Table()
        table.init_round(0, 0, 0, 0, 0, [])
        scores = [230, 110, 55, 405]
        uma = [-17, 3, 48, -34]

        table.set_players_scores(scores, uma)

        self.assertEqual(table.get_player(0).scores, 23000)
        self.assertEqual(table.get_player(0).uma, -17)
        self.assertEqual(table.get_player(1).scores, 11000)
        self.assertEqual(table.get_player(1).uma, 3)
        self.assertEqual(table.get_player(2).scores, 5500)
        self.assertEqual(table.get_player(2).uma, 48)
        self.assertEqual(table.get_player(3).scores, 40500)
        self.assertEqual(table.get_player(3).uma, -34)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:18,代码来源:tests_table.py

示例5: test_round_wind

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_round_wind(self):
        table = Table()

        table.init_round(0, 0, 0, 0, 0, [])
        self.assertEqual(table.round_wind_tile, EAST)

        table.init_round(3, 0, 0, 0, 0, [])
        self.assertEqual(table.round_wind_tile, EAST)

        table.init_round(7, 0, 0, 0, 0, [])
        self.assertEqual(table.round_wind_tile, SOUTH)

        table.init_round(11, 0, 0, 0, 0, [])
        self.assertEqual(table.round_wind_tile, WEST)

        table.init_round(12, 0, 0, 0, 0, [])
        self.assertEqual(table.round_wind_tile, NORTH)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:19,代码来源:tests_table.py

示例6: test_set_names_and_ranks

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_set_names_and_ranks(self):
        table = Table()
        table.init_round(0, 0, 0, 0, 0, [])

        values = [
            {'name': 'NoName', 'rank': u'新人'},
            {'name': 'o2o2', 'rank': u'3級'},
            {'name': 'shimmmmm', 'rank': u'三段'},
            {'name': u'川海老', 'rank': u'9級'}
        ]

        table.set_players_names_and_ranks(values)

        self.assertEqual(table.get_player(0).name, 'NoName')
        self.assertEqual(table.get_player(0).rank, u'新人')
        self.assertEqual(table.get_player(3).name, u'川海老')
        self.assertEqual(table.get_player(3).rank, u'9級')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:19,代码来源:tests_table.py

示例7: test_init_round

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_init_round(self):
        table = Table()

        round_wind_number = 4
        count_of_honba_sticks = 2
        count_of_riichi_sticks = 3
        dora_indicator = 126
        dealer = 3
        scores = [250, 250, 250, 250]

        table.init_round(
            round_wind_number,
            count_of_honba_sticks,
            count_of_riichi_sticks,
            dora_indicator,
            dealer,
            scores
        )

        self.assertEqual(table.round_wind_number, round_wind_number)
        self.assertEqual(table.count_of_honba_sticks, count_of_honba_sticks)
        self.assertEqual(table.count_of_riichi_sticks, count_of_riichi_sticks)
        self.assertEqual(table.dora_indicators[0], dora_indicator)
        self.assertEqual(table.get_player(dealer).is_dealer, True)
        self.assertEqual(table.get_player(dealer).scores, 25000)

        dealer = 2
        table.player.in_tempai = True
        table.player.in_riichi = True
        table.init_round(
            round_wind_number,
            count_of_honba_sticks,
            count_of_riichi_sticks,
            dora_indicator,
            dealer,
            scores
        )

        # test that we reinit round properly
        self.assertEqual(table.get_player(3).is_dealer, False)
        self.assertEqual(table.player.in_tempai, False)
        self.assertEqual(table.player.in_riichi, False)
        self.assertEqual(table.get_player(dealer).is_dealer, True)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:45,代码来源:tests_table.py

示例8: test_set_scores_and_recalculate_player_position

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def test_set_scores_and_recalculate_player_position(self):
        table = Table()
        table.init_round(0, 0, 0, 0, 0, [])

        self.assertEqual(table.get_player(0).first_seat, 0)
        self.assertEqual(table.get_player(1).first_seat, 1)
        self.assertEqual(table.get_player(2).first_seat, 2)
        self.assertEqual(table.get_player(3).first_seat, 3)

        scores = [230, 110, 55, 405]
        table.set_players_scores(scores)

        self.assertEqual(table.get_player(0).position, 2)
        self.assertEqual(table.get_player(1).position, 3)
        self.assertEqual(table.get_player(2).position, 4)
        self.assertEqual(table.get_player(3).position, 1)

        scores = [110, 110, 405, 405]
        table.set_players_scores(scores)

        self.assertEqual(table.get_player(0).position, 3)
        self.assertEqual(table.get_player(1).position, 4)
        self.assertEqual(table.get_player(2).position, 1)
        self.assertEqual(table.get_player(3).position, 2)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:26,代码来源:tests_table.py

示例9: reproduce

# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import init_round [as 别名]
    def reproduce(self, dry_run=False):
        draw_tags = ['T', 'U', 'V', 'W']
        discard_tags = ['D', 'E', 'F', 'G']

        player_draw = draw_tags[self.player_position]

        player_draw_regex = re.compile('^<[{}]+\d*'.format(''.join(player_draw)))
        discard_regex = re.compile('^<[{}]+\d*'.format(''.join(discard_tags)))

        table = Table()
        for tag in self.round_content:
            if player_draw_regex.match(tag) and 'UN' not in tag:
                print('Player draw')
                tile = self.decoder.parse_tile(tag)
                table.player.draw_tile(tile)

            if dry_run:
                if self._is_draw(tag):
                    print('<-', TilesConverter.to_one_line_string([self._parse_tile(tag)]), tag)
                elif self._is_discard(tag):
                    print('->', TilesConverter.to_one_line_string([self._parse_tile(tag)]), tag)
                elif self._is_init_tag(tag):
                    hands = {
                        0: [int(x) for x in self._get_attribute_content(tag, 'hai0').split(',')],
                        1: [int(x) for x in self._get_attribute_content(tag, 'hai1').split(',')],
                        2: [int(x) for x in self._get_attribute_content(tag, 'hai2').split(',')],
                        3: [int(x) for x in self._get_attribute_content(tag, 'hai3').split(',')],
                    }
                    print('Initial hand:', TilesConverter.to_one_line_string(hands[self.player_position]))
                else:
                    print(tag)

            if not dry_run and tag == self.stop_tag:
                break

            if 'INIT' in tag:
                values = self.decoder.parse_initial_values(tag)

                shifted_scores = []
                for x in range(0, 4):
                    shifted_scores.append(values['scores'][self._normalize_position(x, self.player_position)])

                table.init_round(
                    values['round_wind_number'],
                    values['count_of_honba_sticks'],
                    values['count_of_riichi_sticks'],
                    values['dora_indicator'],
                    self._normalize_position(self.player_position, values['dealer']),
                    shifted_scores,
                )

                hands = [
                    [int(x) for x in self.decoder.get_attribute_content(tag, 'hai0').split(',')],
                    [int(x) for x in self.decoder.get_attribute_content(tag, 'hai1').split(',')],
                    [int(x) for x in self.decoder.get_attribute_content(tag, 'hai2').split(',')],
                    [int(x) for x in self.decoder.get_attribute_content(tag, 'hai3').split(',')],
                ]

                table.player.init_hand(hands[self.player_position])

            if discard_regex.match(tag) and 'DORA' not in tag:
                tile = self.decoder.parse_tile(tag)
                player_sign = tag.upper()[1]
                player_seat = self._normalize_position(self.player_position, discard_tags.index(player_sign))

                if player_seat == 0:
                    table.player.discard_tile(tile)
                else:
                    table.add_discarded_tile(player_seat, tile, False)

            if '<N who=' in tag:
                meld = self.decoder.parse_meld(tag)
                player_seat = self._normalize_position(self.player_position, meld.who)
                table.add_called_meld(player_seat, meld)

                if player_seat == 0:
                    # we had to delete called tile from hand
                    # to have correct tiles count in the hand
                    if meld.type != Meld.KAN and meld.type != Meld.CHANKAN:
                        table.player.draw_tile(meld.called_tile)

            if '<REACH' in tag and 'step="1"' in tag:
                who_called_riichi = self._normalize_position(self.player_position,
                                                             self.decoder.parse_who_called_riichi(tag))
                table.add_called_riichi(who_called_riichi)

        if not dry_run:
            tile = self.decoder.parse_tile(self.stop_tag)
            print('Hand: {}'.format(table.player.format_hand_for_print(tile)))

            # to rebuild all caches
            table.player.draw_tile(tile)
            tile = table.player.discard_tile()

            # real run, you can stop debugger here
            table.player.draw_tile(tile)
            tile = table.player.discard_tile()

            print('Discard: {}'.format(TilesConverter.to_one_line_string([tile])))
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:101,代码来源:reproducer.py


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