本文整理汇总了Python中game.table.Table.add_discarded_tile方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_discarded_tile方法的具体用法?Python Table.add_discarded_tile怎么用?Python Table.add_discarded_tile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.table.Table
的用法示例。
在下文中一共展示了Table.add_discarded_tile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_dealer_tile_to_discard
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [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')
示例2: test_defence_against_honitsu_second_case
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_defence_against_honitsu_second_case(self):
table = Table()
tiles = self._string_to_136_array(sou='4', pin='2223456', man='678', honors='66')
table.player.init_hand(tiles)
table.add_called_meld(1, self._make_meld(Meld.CHI, sou='789'))
table.add_called_meld(1, self._make_meld(Meld.PON, honors='444'))
table.add_called_meld(1, self._make_meld(Meld.PON, honors='222'))
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_discarded_tile(1, self._string_to_136_tile(pin='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='3'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='4'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='6'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='7'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='9'), False)
table.add_discarded_tile(1, self._string_to_136_tile(honors='5'), False)
table.add_discarded_tile(1, self._string_to_136_tile(honors='7'), False)
table.player.draw_tile(self._string_to_136_tile(sou='9'))
result = table.player.discard_tile()
self.assertEqual(self._to_string([result]), '3p')
示例3: test_calculate_second_level_ukeire
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_calculate_second_level_ukeire(self):
"""
There was a bug with 2356 form and second level ukeire
"""
table = Table()
player = table.player
table.add_dora_indicator(self._string_to_136_tile(man='2'))
table.add_discarded_tile(1, self._string_to_136_tile(man='2'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='3'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='3'), False)
tiles = self._string_to_136_array(man='34678', pin='2356', sou='4467')
tile = self._string_to_136_tile(sou='8')
player.init_hand(tiles)
player.draw_tile(tile)
discard_options, _ = player.ai.hand_builder.find_discard_options(
player.tiles,
player.closed_hand,
player.melds
)
tile = self._string_to_136_tile(man='4')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 108)
tile = self._string_to_136_tile(man='3')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 108)
tile = self._string_to_136_tile(pin='2')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 96)
tile = self._string_to_136_tile(pin='3')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 96)
tile = self._string_to_136_tile(pin='5')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 96)
tile = self._string_to_136_tile(pin='6')
discard_option = [x for x in discard_options if x.tile_to_discard == tile // 4][0]
player.ai.hand_builder.calculate_second_level_ukeire(discard_option, player.tiles, player.melds)
self.assertEqual(discard_option.ukeire_second, 96)
示例4: test_try_to_discard_not_needed_tiles_first_in_defence_mode
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_try_to_discard_not_needed_tiles_first_in_defence_mode(self):
table = Table()
tiles = self._string_to_136_array(sou='2345678', pin='789', man='55', honors='12')
table.player.init_hand(tiles)
table.add_discarded_tile(1, self._string_to_136_tile(man='5'), False)
table.add_discarded_tile(1, self._string_to_136_tile(honors='1'), False)
table.add_called_riichi(1)
result = table.player.discard_tile()
self.assertEqual(self._to_string([result]), '1z')
示例5: _choose_tanki_with_kabe_helper
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
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)
示例6: test_find_suji_tiles_to_discard_for_one_player
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
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')
示例7: test_temporary_safe_tiles
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_temporary_safe_tiles(self):
table = Table()
table.add_discarded_tile(1, self._string_to_136_tile(man='4'), False)
self.assertEqual(table.get_player(1).temporary_safe_tiles, [])
self.assertEqual(table.get_player(2).temporary_safe_tiles, [3])
self.assertEqual(table.get_player(3).temporary_safe_tiles, [3])
table.add_discarded_tile(2, self._string_to_136_tile(man='5'), False)
self.assertEqual(table.get_player(1).temporary_safe_tiles, [4])
self.assertEqual(table.get_player(2).temporary_safe_tiles, [])
self.assertEqual(table.get_player(3).temporary_safe_tiles, [3, 4])
table.add_discarded_tile(3, self._string_to_136_tile(man='6'), False)
self.assertEqual(table.get_player(1).temporary_safe_tiles, [4, 5])
self.assertEqual(table.get_player(2).temporary_safe_tiles, [5])
self.assertEqual(table.get_player(3).temporary_safe_tiles, [])
table.add_discarded_tile(1, self._string_to_136_tile(man='7'), False)
self.assertEqual(table.get_player(1).temporary_safe_tiles, [])
self.assertEqual(table.get_player(2).temporary_safe_tiles, [5, 6])
self.assertEqual(table.get_player(3).temporary_safe_tiles, [6])
示例8: test_find_common_suji_tiles_to_discard_for_multiple_players
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
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')
示例9: test_mark_dora_as_dangerous_tile_for_suji
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_mark_dora_as_dangerous_tile_for_suji(self):
table = Table()
table.add_dora_indicator(self._string_to_136_tile(man='8'))
tiles = self._string_to_136_array(man='112235', pin='4557788')
table.player.init_hand(tiles)
# 9 man is dora!
table.player.draw_tile(self._string_to_136_tile(man='9'))
table.add_discarded_tile(1, self._string_to_136_tile(man='6'), False)
table.add_called_riichi(1)
result = table.player.discard_tile()
self.assertEqual(self._to_string([result]), '3m')
示例10: test_try_to_discard_less_valuable_tiles_first_in_defence_mode
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_try_to_discard_less_valuable_tiles_first_in_defence_mode(self):
table = Table()
tiles = self._string_to_136_array(sou='234678', pin='6789', man='55', honors='13')
table.player.init_hand(tiles)
table.add_discarded_tile(1, self._string_to_136_tile(pin='7'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='2'), False)
table.add_called_riichi(1)
result = table.player.discard_tile()
# discard of 2s will do less damage to our hand shape than 7p discard
self.assertEqual(table.player.ai.in_defence, True)
self.assertEqual(self._to_string([result]), '2s')
示例11: _choose_furiten_over_karaten_helper
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def _choose_furiten_over_karaten_helper(self, tiles, furiten_tile, karaten_tile, tile_to_draw, tile_to_discard_str):
table = Table()
player = table.player
player.round_step = 2
player.dealer_seat = 3
player.init_hand(tiles)
player.add_discarded_tile(Tile(furiten_tile, True))
for _ in range(0, 3):
table.add_discarded_tile(1, karaten_tile, False)
player.draw_tile(tile_to_draw)
discarded_tile = player.discard_tile()
self.assertEqual(self._to_string([discarded_tile]), tile_to_discard_str)
示例12: test_discard_tile_based_on_second_level_ukeire_and_cost
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_discard_tile_based_on_second_level_ukeire_and_cost(self):
table = Table()
player = table.player
table.add_dora_indicator(self._string_to_136_tile(man='2'))
table.add_discarded_tile(1, self._string_to_136_tile(man='2'), False)
tiles = self._string_to_136_array(man='34678', pin='2356', sou='4467')
tile = self._string_to_136_tile(sou='8')
player.init_hand(tiles)
player.draw_tile(tile)
discarded_tile = player.discard_tile()
discard_correct = self._to_string([discarded_tile]) == '2p' or self._to_string([discarded_tile]) == '3p'
self.assertEqual(discard_correct, True)
示例13: test_dont_discard_safe_tiles_when_call_riichi
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_dont_discard_safe_tiles_when_call_riichi(self):
table = Table()
table.count_of_remaining_tiles = 70
table.player.scores = 2000
tiles = self._string_to_136_array(sou='12356789', pin='22678')
table.player.init_hand(tiles)
table.player.draw_tile(self._string_to_136_tile(honors='1'))
table.player.discard_tile()
table.player.draw_tile(self._string_to_136_tile(honors='1'))
table.add_discarded_tile(1, self._string_to_136_tile(sou='1'), False)
table.add_called_riichi(1)
result = table.player.discard_tile()
self.assertEqual(table.player.can_call_riichi(), True)
self.assertEqual(self._to_string([result]), '1z')
示例14: test_add_safe_tile_after_discard
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_add_safe_tile_after_discard(self):
table = Table()
table.add_called_riichi(3)
table.add_discarded_tile(1, self._string_to_136_tile(man='3'), False)
table.add_discarded_tile(0, self._string_to_136_tile(man='4'), False)
self.assertEqual(len(table.get_player(1).discards), 1)
self.assertEqual(len(table.get_player(2).discards), 0)
self.assertEqual(len(table.get_player(3).discards), 0)
self.assertEqual(len(table.get_player(1).safe_tiles), 1)
self.assertEqual(len(table.get_player(2).safe_tiles), 0)
self.assertEqual(len(table.get_player(3).safe_tiles), 2)
# "2" is 3 man
self.assertEqual(table.get_player(1).safe_tiles, [2])
self.assertEqual(table.get_player(3).safe_tiles, [2, 3])
示例15: test_atodzuke_choose_hidden_syanpon
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_discarded_tile [as 别名]
def test_atodzuke_choose_hidden_syanpon(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='111678', sou='56678', honors='77')
player.init_hand(tiles)
meld = self._make_meld(Meld.PON, man='111')
player.add_called_meld(meld)
strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player)
self.assertEqual(strategy.should_activate_strategy(player.tiles), True)
for _ in range(0, 4):
table.add_discarded_tile(1, self._string_to_136_tile(sou='9'), False)
player.draw_tile(self._string_to_136_tile(man='6'))
discarded_tile = player.discard_tile()
self.assertNotEqual(self._to_string([discarded_tile]), '6m')