def test_call_shouminkan_and_bad_ukeire_after_call(): table = Table() table.count_of_remaining_tiles = 10 tiles = string_to_136_array(man="34445", sou="123456", pin="89") table.player.init_hand(tiles) tile = string_to_136_array(man="4444")[3] table.player.draw_tile(tile) assert table.player.should_call_kan(tile, False) is None table.player.add_called_meld(make_meld(MeldPrint.PON, man="444")) assert len(table.player.melds) == 1 assert table.player.should_call_kan(tile, False) is None
def test_call_shouminkan_and_bad_ukeire_after_call_second_case(): table = Table() table.add_dora_indicator(string_to_136_tile(honors="5")) table.count_of_remaining_tiles = 10 player = table.player tiles = string_to_136_array(man="3455567", sou="222", honors="666") player.init_hand(tiles) player.add_called_meld(make_meld(MeldPrint.PON, man="555")) player.add_called_meld(make_meld(MeldPrint.PON, honors="666")) tile = string_to_136_array(man="5555")[3] player.draw_tile(tile) assert player.should_call_kan(tile, False) is None
def test_dont_open_hand_with_high_shanten(): table = _make_table() # with 4 shanten we don't need to aim for open tanyao tiles = string_to_136_array(man="269", pin="247", sou="2488", honors="123") tile = string_to_136_tile(sou="3") table.player.init_hand(tiles) meld, _ = table.player.try_to_call_meld(tile, False) assert meld is None # with 3 shanten we can open a hand tiles = string_to_136_array(man="236", pin="247", sou="2488", honors="123") tile = string_to_136_tile(sou="3") table.player.init_hand(tiles) meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None
def test_should_activate_strategy(): table = Table() player = table.player strategy = HonitsuStrategy(BaseStrategy.HONITSU, player) table.add_dora_indicator(string_to_136_tile(pin="1")) table.add_dora_indicator(string_to_136_tile(honors="5")) tiles = string_to_136_array(sou="12355", man="12389", honors="123") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # many tiles in one suit and yakuhai pair, but still many useless winds tiles = string_to_136_array(sou="12355", man="23", pin="68", honors="2355") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # many tiles in one suit and yakuhai pair and another honor pair, so # now this is honitsu tiles = string_to_136_array(sou="12355", man="238", honors="22355") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is True # same conditions, but ready suit with dora in another suit, so no honitsu tiles = string_to_136_array(sou="12355", pin="234", honors="22355") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # same conditions, but we have a pon of yakuhai doras, we shouldn't # force honitsu with this hand tiles = string_to_136_array(sou="12355", pin="238", honors="22666") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # if we have a complete set with dora, we shouldn't go for honitsu tiles = string_to_136_array(sou="11123688", pin="123", honors="55") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # even if the set may be interpreted as two forms tiles = string_to_136_array(sou="1223688", pin="2334", honors="55") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # even if the set may be interpreted as two forms v2 tiles = string_to_136_array(sou="1223688", pin="2345", honors="55") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False # if we have a long form with dora, we shouldn't go for honitsu tiles = string_to_136_array(sou="1223688", pin="2333", honors="55") player.init_hand(tiles) assert strategy.should_activate_strategy(player.tiles) is False
def test_kuikae_simple(): # case 1: simple chi table = _make_table() table.add_dora_indicator(string_to_136_tile(pin="2")) # but with opened hand we don't need to count not suitable tiles as ukeire tiles = string_to_136_array(man="234678", sou="135", pin="3335") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.CHI, man="234")) tile = string_to_136_tile(sou="4") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None # case 2: kuikae table = _make_table() table.add_dora_indicator(string_to_136_tile(pin="2")) # but with opened hand we don't need to count not suitable tiles as ukeire tiles = string_to_136_array(man="234678", sou="123", pin="3335") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.CHI, man="234")) tile = string_to_136_tile(sou="4") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # case 3: no kuikae can be applie to pon table = _make_table() table.add_dora_indicator(string_to_136_tile(pin="2")) # but with opened hand we don't need to count not suitable tiles as ukeire tiles = string_to_136_array(man="234678", sou="144", pin="3335") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.CHI, man="234")) tile = string_to_136_tile(sou="4") meld, _ = table.player.try_to_call_meld(tile, False) assert meld is not None # case 4: no false kuikae table = _make_table() table.add_dora_indicator(string_to_136_tile(pin="2")) # but with opened hand we don't need to count not suitable tiles as ukeire tiles = string_to_136_array(man="234678", sou="237", pin="3335") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.CHI, man="234")) tile = string_to_136_tile(sou="4") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None
def test_dont_open_hand_with_not_suitable_melds(): table = _make_table() tiles = string_to_136_array(man="22255788", sou="3479", honors="3") tile = string_to_136_tile(sou="8") table.player.init_hand(tiles) meld, _ = table.player.try_to_call_meld(tile, False) assert meld is None
def test_tile_danger_and_2_8_suji_tiles(): enemy_seat = 1 table = _create_table(enemy_seat, discards=[], riichi_tile=string_to_136_tile(honors="7")) player = table.player table.add_discarded_tile(enemy_seat, string_to_136_tile(sou="4"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(sou="5"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(sou="6"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(man="2"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(man="3"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(man="8"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(man="9"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="1"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="7"), False) tiles = string_to_136_array(sou="2378", pin="4", man="56", honors="233555") tile = string_to_136_tile(honors="3") player.init_hand(tiles) player.draw_tile(tile) _assert_discard(player, enemy_seat, TileDanger.SUJI, sou="2") _assert_discard(player, enemy_seat, TileDanger.SUJI, sou="3") _assert_discard(player, enemy_seat, TileDanger.SUJI, sou="7") _assert_discard(player, enemy_seat, TileDanger.SUJI, sou="8") _assert_discard(player, enemy_seat, TileDanger.SUJI, pin="4") _assert_discard(player, enemy_seat, TileDanger.SUJI, man="5") _assert_discard(player, enemy_seat, TileDanger.SUJI, man="6")
def test_atodzuke_dont_open_no_yaku_tempai(): # make sure yakuhai strategy is activated by adding 3 doras to the hand table = Table() player = table.player table.add_dora_indicator(string_to_136_tile(man="9")) tiles = string_to_136_array(man="111445", sou="567", pin="56", honors="77") player.init_hand(tiles) meld = make_meld(MeldPrint.PON, man="111") player.add_called_meld(meld) # 6 man is bad meld, we lose our second pair and so is 4 man tile = string_to_136_tile(man="6") meld, _ = player.try_to_call_meld(tile, True) assert meld is None strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player) assert strategy.should_activate_strategy(player.tiles) is True tile = string_to_136_tile(man="4") meld, _ = player.try_to_call_meld(tile, True) assert meld is None strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player) assert strategy.should_activate_strategy(player.tiles) is True # 7 pin is a good meld, we get to tempai keeping yakuhai wait tile = string_to_136_tile(pin="7") meld, _ = player.try_to_call_meld(tile, True) assert meld is not None strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, player) assert strategy.should_activate_strategy(player.tiles) is True
def test_open_double_south_wind(): table = Table() tiles = string_to_136_array(man="59", sou="1235", pin="12788", honors="22") table.player.init_hand(tiles) tile = string_to_136_tile(honors="2") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # player is south and round is south table.round_wind_number = 5 table.player.dealer_seat = 3 assert table.player.player_wind == SOUTH table.player.init_hand(tiles) tile = string_to_136_tile(honors="2") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # add dora in the hand and after that we can open a hand table.dora_indicators.append(string_to_136_tile(pin="6")) table.player.init_hand(tiles) tile = string_to_136_tile(honors="2") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None
def test_open_hand_and_once_discarded_tile(): """ If we have valuable pair in the hand, this tile was discarded once and we have 1+ shanten let's open on this valuable pair """ table = Table() strategy = YakuhaiStrategy(BaseStrategy.YAKUHAI, table.player) tiles = string_to_136_array(sou="678", pin="14689", man="456", honors="77") table.player.init_hand(tiles) # we don't activate strategy yet assert strategy.should_activate_strategy(table.player.tiles) is False # let's skip first yakuhai early in the game tile = string_to_136_tile(honors="7") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # now one is out table.add_discarded_tile(1, tile, False) meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None assert tiles_to_string(meld.tiles) == "777z" # but we don't need to open hand for atodzuke here tile = string_to_136_tile(pin="7") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None
def test_should_activate_strategy_and_terminal_pon_sets(): table = _make_table() strategy = TanyaoStrategy(BaseStrategy.TANYAO, table.player) tiles = string_to_136_array(sou="222", man="3459", pin="233", honors="111") table.player.init_hand(tiles) assert strategy.should_activate_strategy(table.player.tiles) is False tiles = string_to_136_array(sou="222", man="3459", pin="233999") table.player.init_hand(tiles) assert strategy.should_activate_strategy(table.player.tiles) is False tiles = string_to_136_array(sou="222", man="3459", pin="233444") table.player.init_hand(tiles) assert strategy.should_activate_strategy(table.player.tiles) is True
def test_open_hand_with_doras_in_the_hand(): """ If we have valuable pair in the hand, and 2+ dora let's open on this valuable pair """ table = Table() table.player.dealer_seat = 3 tiles = string_to_136_array(man="59", sou="1235", pin="12789", honors="11") table.player.init_hand(tiles) tile = string_to_136_tile(honors="1") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # add doras to the hand table.dora_indicators.append(string_to_136_tile(pin="7")) table.dora_indicators.append(string_to_136_tile(pin="8")) table.player.init_hand(tiles) # and now we can open hand on the valuable pair tile = string_to_136_tile(honors="1") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None # but we don't need to open hand for atodzuke here tile = string_to_136_tile(pin="3") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None
def test_calculate_our_hand_cost_1_shanten(): table = _make_table() player = table.player enemy_seat = 2 table.has_open_tanyao = True table.has_aka_dora = False enemy_called_riichi_helper(table, enemy_seat) tiles = string_to_136_array(sou="22245677", pin="145", man="67") tile = string_to_136_tile(honors="1") player.init_hand(tiles) player.add_called_meld(make_meld(MeldPrint.PON, sou="222")) player.draw_tile(tile) discard_option = find_discard_option(player, honors="1") cost = discard_option.average_second_level_cost assert cost == 1500 table.add_dora_indicator(string_to_136_tile(sou="6")) discard_option = find_discard_option(player, honors="1") cost = discard_option.average_second_level_cost assert cost == 5850 table.add_dora_indicator(string_to_136_tile(pin="2")) discard_option = find_discard_option(player, honors="1") cost = discard_option.average_second_level_cost assert cost == 8737
def test_must_push_1st_and_4th_place_riichi(): table = Table() player = table.player table.has_aka_dora = True table.has_open_tanyao = True # orasu table.round_wind_number = 7 table.dealer_seat = 1 player.dealer_seat = 1 table.add_dora_indicator(string_to_136_tile(sou="1")) # we have 1-shanten with no doras, but we must push because we have 4th place in oorasu tiles = string_to_136_array(man="3488", sou="334678", pin="456") table.player.init_hand(tiles) table.player.round_step = 5 player.scores = 45000 assert table.players[0] == player table.players[1].scores = 42000 table.players[2].scores = 5000 table.players[3].scores = 8000 enemy_seat = 3 table.add_called_riichi_step_one(enemy_seat) threatening_players = table.player.ai.defence.get_threatening_players() assert len(threatening_players) == 1 assert not player.ai.placement.must_push(threatening_players, 0, 1)
def test_skip_cheap_meld_1_shanten_can_move_to_west(): table = Table() player = table.player table.has_aka_dora = True table.has_open_tanyao = True # orasu table.round_wind_number = 7 table.dealer_seat = 1 player.dealer_seat = 1 table.add_dora_indicator(string_to_136_tile(sou="2")) tiles = string_to_136_array(man="3488", sou="334678", pin="268") table.player.init_hand(tiles) table.player.round_step = 12 player.scores = 18000 assert table.players[0] == player table.players[1].scores = 28000 table.players[2].scores = 29000 table.players[3].scores = 31000 # it's cheap, but with ron from first place we can move game to west round, so let's do it tile = string_to_136_tile(sou="2") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None # now this is the cost we might win with tile = string_to_136_tile(sou="3") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None
def test_skip_cheap_meld_2_shanten(): table = Table() player = table.player table.has_aka_dora = True table.has_open_tanyao = True # orasu table.round_wind_number = 7 table.dealer_seat = 1 player.dealer_seat = 1 table.add_dora_indicator(string_to_136_tile(sou="2")) tiles = string_to_136_array(man="34889", sou="33468", pin="268") table.player.init_hand(tiles) table.player.round_step = 12 player.scores = 18000 assert table.players[0] == player table.players[1].scores = 28000 table.players[2].scores = 35000 table.players[3].scores = 40000 # it's too cheap, let's not open tile = string_to_136_tile(sou="2") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # now this is the cost we might win with tile = string_to_136_tile(sou="3") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None
def test_skip_ron_in_west_4(): table = Table() player = table.player table.has_aka_dora = True table.has_open_tanyao = True # orasu table.round_wind_number = 11 table.dealer_seat = 1 player.dealer_seat = 1 table.add_dora_indicator(string_to_136_tile(sou="1")) tiles = string_to_136_array(man="23488", sou="34678", pin="567") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.CHI, pin="567")) table.player.round_step = 14 player.scores = 20100 assert table.players[0] == player table.players[1].scores = 22000 table.players[2].scores = 26000 table.players[3].scores = 29900 assert player.should_call_win(string_to_136_tile(sou="5"), False, 1) assert not player.should_call_win(string_to_136_tile(sou="5"), False, 2) assert not player.should_call_win(string_to_136_tile(sou="5"), False, 3)
def test_tile_danger_and_non_yakuhai_honor_second(): enemy_seat = 1 table = _create_table(enemy_seat, discards=string_to_136_array(honors="4"), riichi_tile=string_to_136_tile(honors="7")) player = table.player tiles = string_to_136_array(man="11134", pin="1156", honors="4555") tile = string_to_136_tile(sou="8") player.init_hand(tiles) player.draw_tile(tile) _assert_discard(player, enemy_seat, TileDanger.NON_YAKUHAI_HONOR_SECOND_EARLY, honors="4")
def test_should_activate_strategy_and_chitoitsu_like_hand(): table = _make_table() strategy = TanyaoStrategy(BaseStrategy.TANYAO, table.player) tiles = string_to_136_array(sou="223388", man="2244", pin="6687") table.player.init_hand(tiles) assert strategy.should_activate_strategy(table.player.tiles) is True
def test_open_hand_with_two_valuable_pairs(): """ If we have two valuable pairs in the hand and 1+ dora or we are dealer let's open on one of this valuable pairs """ table = Table() table.player.seat = 3 tiles = string_to_136_array(man="159", sou="128", pin="789", honors="5566") table.player.init_hand(tiles) tile = string_to_136_tile(honors="5") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None # add doras to the hand table.dora_indicators.append(string_to_136_tile(pin="7")) table.player.init_hand(tiles) tile = string_to_136_tile(honors="5") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None tile = string_to_136_tile(honors="6") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is not None # but we don't need to open hand for atodzuke here tile = string_to_136_tile(pin="3") meld, _ = table.player.try_to_call_meld(tile, True) assert meld is None
def test_remaining_tiles_and_opened_meld(): table = Table() player = table.player tiles = string_to_136_array(man="123456789", sou="167", honors="77") player.init_hand(tiles) results, shanten = player.ai.hand_builder.find_discard_options() result = [x for x in results if x.tile_to_discard_34 == string_to_34_tile(sou="1")][0] assert result.ukeire == 8 # was discard and set was opened tile = string_to_136_tile(sou="8") player.table.add_discarded_tile(3, tile, False) meld = make_meld(MeldPrint.PON, sou="888") meld.called_tile = tile player.table.add_called_meld(3, meld) results, shanten = player.ai.hand_builder.find_discard_options() result = [x for x in results if x.tile_to_discard_34 == string_to_34_tile(sou="1")][0] assert result.ukeire == 5 # was discard and set was opened tile = string_to_136_tile(sou="3") player.table.add_discarded_tile(2, tile, False) meld = make_meld(MeldPrint.PON, sou="345") meld.called_tile = tile player.table.add_called_meld(2, meld) results, shanten = player.ai.hand_builder.find_discard_options() result = [x for x in results if x.tile_to_discard_34 == string_to_34_tile(sou="1")][0] assert result.ukeire == 4
def test_opened_kan_and_threatening_riichi(): table = Table() table.count_of_remaining_tiles = 10 enemy_seat = 2 table.add_called_riichi_step_one(enemy_seat) threatening_players = table.player.ai.defence.get_threatening_players() assert len(threatening_players) == 1 assert threatening_players[0].enemy.seat == enemy_seat assert threatening_players[0].threat_reason[ "id"] == EnemyDanger.THREAT_RIICHI["id"] tiles = string_to_136_array(man="2399", sou="111456", honors="111") table.player.init_hand(tiles) table.player.add_called_meld(make_meld(MeldPrint.PON, honors="111")) # to rebuild all caches table.player.draw_tile(string_to_136_tile(pin="9")) table.player.discard_tile() # our hand is open, in tempai and with a good wait but there is a riichi so calling open kan is a bad idea tile = string_to_136_tile(sou="1") assert table.player.should_call_kan(tile, True) is None assert table.player.try_to_call_meld(tile, True) == (None, None)
def test_tile_danger_early_discard_early(): enemy_seat = 1 table = Table() table.has_aka_dora = True player = table.player tiles = string_to_136_array(man="11345", pin="11289", honors="5", sou="19") tile = string_to_136_tile(man="9") player.init_hand(tiles) player.draw_tile(tile) table.add_discarded_tile(enemy_seat, string_to_136_tile(sou="2"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(sou="5"), False) table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="7"), True) table.add_discarded_tile(enemy_seat, string_to_136_tile(pin="1"), True) enemy_called_riichi_helper(table, enemy_seat, string_to_136_tile(pin="4")) # too early to judge about early discards _assert_discard_not_equal(player, enemy_seat, TileDanger.BONUS_EARLY_28, sou="1") _assert_discard_not_equal(player, enemy_seat, TileDanger.BONUS_EARLY_5, sou="9") _assert_discard_not_equal(player, enemy_seat, TileDanger.BONUS_EARLY_37, pin="8") _assert_discard_not_equal(player, enemy_seat, TileDanger.BONUS_EARLY_37, pin="9")
def test_choose_furiten_over_karaten(): _choose_furiten_over_karaten_helper( string_to_136_array(man="22336688", pin="99", honors="267"), string_to_136_tile(honors="6"), string_to_136_tile(honors="7"), string_to_136_tile(honors="2"), "7z", ) _choose_furiten_over_karaten_helper( string_to_136_array(man="22336688", pin="99", honors="267"), string_to_136_tile(honors="7"), string_to_136_tile(honors="6"), string_to_136_tile(honors="2"), "6z", )
def test_avoid_furiten(): _avoid_furiten_helper( string_to_136_array(man="22336688", pin="99", honors="267"), string_to_136_tile(honors="6"), string_to_136_tile(honors="7"), string_to_136_tile(honors="2"), "6z", ) _avoid_furiten_helper( string_to_136_array(man="22336688", pin="99", honors="267"), string_to_136_tile(honors="7"), string_to_136_tile(honors="6"), string_to_136_tile(honors="2"), "7z", )
def test_choose_correct_wait_yaku_potentially(): table = Table() player = table.player player.round_step = 2 tiles = string_to_136_array(man="1134578", sou="567788") player.init_hand(tiles) player.draw_tile(string_to_136_tile(man="9")) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "5s" tiles = string_to_136_array(man="1134578", sou="556678") player.init_hand(tiles) player.draw_tile(string_to_136_tile(man="9")) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "8s"
def test_discard_tile(): table = Table() player = table.player tiles = string_to_136_array(sou="11134567", pin="159", man="45") tile = string_to_136_tile(man="9") player.init_hand(tiles) player.draw_tile(tile) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "9m" or tiles_to_string( [discarded_tile]) == "9p" assert player.ai.shanten == 2 player.draw_tile(string_to_136_tile(pin="4")) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "1p" assert player.ai.shanten == 2 player.draw_tile(string_to_136_tile(pin="3")) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "9p" or tiles_to_string( [discarded_tile]) == "9m" assert player.ai.shanten == 1 player.draw_tile(string_to_136_tile(man="4")) discarded_tile, _ = player.discard_tile() assert tiles_to_string([discarded_tile]) == "5m" assert player.ai.shanten == 0
def test_open_hand_and_discard_tiles_logic(): table = Table() player = table.player tiles = string_to_136_array(sou="112235589", man="23", honors="66") player.init_hand(tiles) # we don't need to call meld even if it improves our hand, # because we are aim for honitsu or pinfu tile = string_to_136_tile(man="1") meld, _ = player.try_to_call_meld(tile, False) assert meld is None # any honor tile is suitable tile = string_to_136_tile(honors="6") meld, discard_option = player.try_to_call_meld(tile, False) assert meld is not None assert tiles_to_string([discard_option.tile_to_discard_136]) == "2m" tile = string_to_136_tile(man="1") player.draw_tile(tile) tile_to_discard = player.discard_tile() # we are in honitsu mode, so we should discard man suits assert tiles_to_string([tile_to_discard]) == "1m"
def test_crash_when_tyring_to_open_meld(): """ Bot crashed when tried to calculate meld possibility with hand 7m333789s + 3s [222z, 123p] This test is checking that there are no crashes in such situations anymore """ # checking a few similar hands here # #1 table = Table() # dora here to activate honitsu strategy table.add_dora_indicator(string_to_136_tile(sou="9")) player = table.player tiles = string_to_136_array(sou="1112345678", honors="447") player.init_hand(tiles) tile = string_to_136_array(sou="1111")[3] meld, _ = player.try_to_call_meld(tile, False) assert meld is not None # #2 table = Table() # dora here to activate honitsu strategy table.add_dora_indicator(string_to_136_tile(sou="9")) player = table.player tiles = string_to_136_array(sou="11123456789", honors="47") player.init_hand(tiles) tile = string_to_136_array(sou="1111")[3] meld, _ = player.try_to_call_meld(tile, False) assert meld is not None # #3 table = Table() # dora here to activate honitsu strategy table.add_dora_indicator(string_to_136_tile(sou="9")) player = table.player tiles = string_to_136_array(sou="111234567", honors="4444") player.init_hand(tiles) table.add_called_meld(player.seat, make_meld(MeldPrint.PON, honors="444")) tile = string_to_136_array(sou="1111")[3] meld, _ = player.try_to_call_meld(tile, False) assert meld is not None # #4 - the original one table = Table() # dora here to activate yakuhai strategy table.add_dora_indicator(string_to_136_tile(sou="2")) player = table.player tiles = string_to_136_array(man="7", pin="123", sou="333789", honors="111") player.init_hand(tiles) table.add_called_meld(player.seat, make_meld(MeldPrint.PON, honors="111")) table.add_called_meld(player.seat, make_meld(MeldPrint.CHI, pin="123")) # it is important for crash to take fourth 3s (with index 83) tile = string_to_136_array(sou="3333")[3] meld, _ = player.try_to_call_meld(tile, False) assert meld is None
def test_riichi_tanki_honor_chiitoitsu(): table = _make_table() tiles = string_to_136_array(man="22336688", sou="99", pin="99", honors="2") table.player.init_hand(tiles) table.player.draw_tile(string_to_136_tile(honors="3")) table.player.discard_tile() assert table.player.can_call_riichi() is True