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


Python table.Table类代码示例

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


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

示例1: test_choose_better_tanki_honor

    def test_choose_better_tanki_honor(self):
        table = Table()
        player = table.player
        player.round_step = 2
        player.dealer_seat = 3

        table.add_dora_indicator(self._string_to_136_tile(man='8'))

        tiles = self._string_to_136_array(man='11447799', sou='556', honors='45')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(honors='4'))
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '6s')

        tiles = self._string_to_136_array(man='11447799', sou='556', honors='45')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(honors='5'))
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '6s')

        tiles = self._string_to_136_array(man='11447799', sou='556', honors='45')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(sou='6'))
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '5z')

        tiles = self._string_to_136_array(man='11447799', sou='556', honors='34')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(sou='6'))
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '3z')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:31,代码来源:tests_discards.py

示例2: test_find_dealer_tile_to_discard

    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,代码行数:33,代码来源:tests_defence.py

示例3: test_discard_tile_force_tsumogiri

    def test_discard_tile_force_tsumogiri(self):
        table = Table()
        table.has_aka_dora = True
        player = table.player

        tiles = self._string_to_136_array(sou='11134567', pin='456', man='45')
        # 6p
        tile = 57

        player.init_hand(tiles)
        player.draw_tile(tile)

        discarded_tile = player.discard_tile()
        self.assertEqual(discarded_tile, tile)

        # add not red five pin
        tiles = self._string_to_136_array(sou='11134567', pin='46', man='45') + [53]
        tile = FIVE_RED_PIN

        player.init_hand(tiles)
        player.draw_tile(tile)

        discarded_tile = player.discard_tile()
        # WE DON'T NEED TO DISCARD RED FIVE
        self.assertNotEqual(discarded_tile, tile)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:25,代码来源:tests_discards.py

示例4: test_atodzuke_dont_open_no_yaku_tempai

    def test_atodzuke_dont_open_no_yaku_tempai(self):
        # make sure yakuhai strategy is activated by adding 3 doras to the hand
        table = Table()
        player = table.player
        table.add_dora_indicator(self._string_to_136_tile(man='9'))

        tiles = self._string_to_136_array(man='111445', sou='567', pin='56', honors='77')
        player.init_hand(tiles)

        meld = self._make_meld(Meld.PON, man='111')
        player.add_called_meld(meld)

        # 6 man is bad meld, we lose our second pair and so is 4 man
        tile = self._string_to_136_tile(man='6')
        meld, _ = player.try_to_call_meld(tile, True)
        self.assertEqual(meld, None)

        strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player)
        self.assertEqual(strategy.should_activate_strategy(player.tiles), True)

        tile = self._string_to_136_tile(man='4')
        meld, _ = player.try_to_call_meld(tile, True)
        self.assertEqual(meld, None)

        strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player)
        self.assertEqual(strategy.should_activate_strategy(player.tiles), True)

        # 7 pin is a good meld, we get to tempai keeping yakuhai wait
        tile = self._string_to_136_tile(pin='7')
        meld, _ = player.try_to_call_meld(tile, True)
        self.assertNotEqual(meld, None)

        strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player)
        self.assertEqual(strategy.should_activate_strategy(player.tiles), True)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:34,代码来源:tests_yakuhai.py

示例5: test_discard_tile_with_better_wait_in_iishanten

    def test_discard_tile_with_better_wait_in_iishanten(self):
        table = Table()
        player = table.player
        table.add_dora_indicator(self._string_to_136_tile(sou='4'))

        tiles = self._string_to_136_array(man='123567', pin='113788', sou='99')
        player.init_hand(tiles)

        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '8p')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:10,代码来源:tests_discards.py

示例6: test_detect_enemy_tempai_and_riichi

    def test_detect_enemy_tempai_and_riichi(self):
        table = Table()

        self.assertEqual(EnemyAnalyzer(table.get_player(1)).in_tempai, False)
        self.assertEqual(EnemyAnalyzer(table.get_player(1)).is_threatening, False)

        table.add_called_riichi(1)

        self.assertEqual(EnemyAnalyzer(table.get_player(1)).in_tempai, True)
        self.assertEqual(EnemyAnalyzer(table.get_player(1)).is_threatening, True)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:10,代码来源:tests_enemy_analyzer.py

示例7: test_discard_tile_with_max_ukeire_second_level

    def test_discard_tile_with_max_ukeire_second_level(self):
        table = Table()
        player = table.player
        table.add_dora_indicator(self._string_to_136_tile(sou='4'))

        tiles = self._string_to_136_array(sou='11367', pin='45', man='344778')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(pin='6'))

        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '3s')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:11,代码来源:tests_discards.py

示例8: test_prefer_valuable_tiles_with_almost_same_ukeire

    def test_prefer_valuable_tiles_with_almost_same_ukeire(self):
        table = Table()
        player = table.player
        table.add_dora_indicator(self._string_to_136_tile(sou='4'))

        tiles = self._string_to_136_array(sou='1366', pin='123456', man='345')
        player.init_hand(tiles)
        player.draw_tile(self._string_to_136_tile(sou='5'))

        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '1s')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:11,代码来源:tests_discards.py

示例9: test_slide_set_to_keep_dora_in_hand

    def test_slide_set_to_keep_dora_in_hand(self):
        table = Table()
        table.dora_indicators = [self._string_to_136_tile(pin='9')]
        player = table.player

        tiles = self._string_to_136_array(sou='123456', pin='23478', man='99')
        tile = self._string_to_136_tile(pin='1')
        player.init_hand(tiles)
        player.draw_tile(tile)

        # 2p is a dora, we had to keep it
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), '4p')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:13,代码来源:tests_discards.py

示例10: _choose_tanki_with_kabe_helper

    def _choose_tanki_with_kabe_helper(self, tiles, kabe_tiles, tile_to_draw, tile_to_discard_str):
        table = Table()
        player = table.player
        player.round_step = 2
        player.dealer_seat = 3

        for tile in kabe_tiles:
            for _ in range(0, 4):
                table.add_discarded_tile(1, tile, False)

        player.init_hand(tiles)
        player.draw_tile(tile_to_draw)
        discarded_tile = player.discard_tile()
        self.assertEqual(self._to_string([discarded_tile]), tile_to_discard_str)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:14,代码来源:tests_discards.py

示例11: test_find_suji_tiles_to_discard_for_one_player

    def test_find_suji_tiles_to_discard_for_one_player(self):
        table = Table()

        tiles = self._string_to_136_array(sou='2345678', pin='12789', man='55')
        table.player.init_hand(tiles)

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

        table.add_called_riichi(1)

        result = table.player.discard_tile()

        self.assertEqual(self._to_string([result]), '5m')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:14,代码来源:tests_defence.py

示例12: test_call_riichi_with_bad_wait_against_other_player_riichi

    def test_call_riichi_with_bad_wait_against_other_player_riichi(self):
        table = Table()
        table.count_of_remaining_tiles = 60
        table.player.scores = 25000

        tiles = self._string_to_136_array(sou='11223', pin='234678', man='55')
        table.player.init_hand(tiles)
        table.player.draw_tile(self._string_to_136_tile(man='9'))

        table.add_called_riichi(3)

        discard = table.player.discard_tile()
        self.assertEqual(self._to_string([discard]), '9m')
        self.assertEqual(table.player.ai.in_defence, True)
        self.assertEqual(table.player.can_call_riichi(), False)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:15,代码来源:tests_defence.py

示例13: test_keep_aka_dora_in_hand

    def test_keep_aka_dora_in_hand(self):
        table = Table()
        table.dora_indicators = [self._string_to_136_tile(pin='1')]
        table.has_aka_dora = True
        player = table.player

        tiles = self._string_to_136_array(sou='12346', pin='34578', man='99')
        # five sou, we can't get it from string (because from string it is always aka dora)
        tiles += [89]
        player.init_hand(tiles)
        player.draw_tile(FIVE_RED_SOU)

        # we had to keep red five and discard just 5s
        discarded_tile = player.discard_tile()
        self.assertNotEqual(discarded_tile, FIVE_RED_SOU)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:15,代码来源:tests_discards.py

示例14: test_find_common_suji_tiles_to_discard_for_multiple_players

    def test_find_common_suji_tiles_to_discard_for_multiple_players(self):
        table = Table()

        tiles = self._string_to_136_array(sou='2345678', pin='12789', man='55')
        table.player.init_hand(tiles)

        table.add_discarded_tile(1, self._string_to_136_tile(pin='4'), False)
        table.add_discarded_tile(2, self._string_to_136_tile(pin='4'), False)

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

        result = table.player.discard_tile()

        self.assertEqual(self._to_string([result]), '1p')
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:15,代码来源:tests_defence.py

示例15: test_open_hand_when_yakuhai_already_in_the_hand

    def test_open_hand_when_yakuhai_already_in_the_hand(self):
        # make sure yakuhai strategy is activated by adding 3 doras to the hand
        table = Table()
        player = table.player
        table.add_dora_indicator(self._string_to_136_tile(honors='5'))

        tiles = self._string_to_136_array(man='46', pin='4679', sou='1348', honors='666')
        player.init_hand(tiles)

        strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player)
        self.assertEqual(strategy.should_activate_strategy(player.tiles), True)

        tile = self._string_to_136_tile(sou='2')
        meld, _ = player.try_to_call_meld(tile, True)
        self.assertNotEqual(meld, None)
开发者ID:MahjongRepository,项目名称:tenhou-python-bot,代码行数:15,代码来源:tests_yakuhai.py


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