本文整理汇总了Python中game.table.Table.add_called_meld方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_called_meld方法的具体用法?Python Table.add_called_meld怎么用?Python Table.add_called_meld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.table.Table
的用法示例。
在下文中一共展示了Table.add_called_meld方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_defence_against_honitsu_second_case
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_called_meld [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')
示例2: test_try_to_detect_honitsu_hand
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_called_meld [as 别名]
def test_try_to_detect_honitsu_hand(self):
table = Table()
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='567'))
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='123'))
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='345'))
table.add_discarded_tile(1, self._string_to_136_tile(sou='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='5'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='8'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='9'), False)
table.add_discarded_tile(1, self._string_to_136_tile(man='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(man='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='1'), False)
self.assertEqual(EnemyAnalyzer(table.get_player(1)).is_threatening, True)
self.assertEqual(EnemyAnalyzer(table.get_player(1)).chosen_suit, is_pin)
示例3: test_detect_enemy_tempai_and_opened_sets
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_called_meld [as 别名]
def test_detect_enemy_tempai_and_opened_sets(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_meld(1, self._make_meld(Meld.CHI, sou='567'))
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='123'))
table.add_called_meld(1, self._make_meld(Meld.CHI, man='345'))
table.add_called_meld(1, self._make_meld(Meld.PON, man='777'))
self.assertEqual(EnemyAnalyzer(table.get_player(1)).in_tempai, True)
self.assertEqual(EnemyAnalyzer(table.get_player(1)).is_threatening, False)
table.dora_indicators = [self._string_to_136_tile(man='6')]
# enemy opened the pon of dor, so better to fold against him
self.assertEqual(EnemyAnalyzer(table.get_player(1)).in_tempai, True)
self.assertEqual(EnemyAnalyzer(table.get_player(1)).is_threatening, True)
示例4: test_defence_against_honitsu_first_case
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_called_meld [as 别名]
def test_defence_against_honitsu_first_case(self):
table = Table()
tiles = self._string_to_136_array(sou='22', pin='222367899', man='45', honors='1')
table.player.init_hand(tiles)
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='567'))
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='123'))
table.add_called_meld(1, self._make_meld(Meld.CHI, pin='345'))
table.add_discarded_tile(1, self._string_to_136_tile(sou='6'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='6'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='8'), False)
table.add_discarded_tile(1, self._string_to_136_tile(sou='9'), False)
table.add_discarded_tile(1, self._string_to_136_tile(man='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(man='1'), False)
table.add_discarded_tile(1, self._string_to_136_tile(pin='5'), False)
result = table.player.discard_tile()
# we can't discard pin and honor tiles against honitsu
self.assertEqual(self._to_string([result]), '2s')
示例5: reproduce
# 需要导入模块: from game.table import Table [as 别名]
# 或者: from game.table.Table import add_called_meld [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])))