MahjongRepository/mahjong

Problem of All Green

paulzzh opened this issue · 0 comments

Hi,I have tried the following code:

from mahjong.hand_calculating.hand import HandCalculator
from mahjong.meld import Meld
from mahjong.hand_calculating.hand_config import HandConfig, OptionalRules
from mahjong.shanten import Shanten
from mahjong.tile import TilesConverter
calculator = HandCalculator()
# useful helper
def print_hand_result(hand_result):
    print(hand_result.han, hand_result.fu)
    print(hand_result.cost['main'])
    print(hand_result.yaku)
    for fu_item in hand_result.fu_details:
        print(fu_item)
    print('')
# we had to use all 14 tiles in that array

#CHI 234s
chi=Meld(meld_type=Meld.CHI, tiles=TilesConverter.string_to_136_array(sou='234'))
melds = [chi,chi,chi,chi]

# 6s6s 234s 234s 234s 234s
tiles = TilesConverter.string_to_136_array(sou='23423423423466')
win_tile = TilesConverter.string_to_136_array(sou='6')[0]
result = calculator.estimate_hand_value(tiles, win_tile, melds=melds, config=HandConfig(options=OptionalRules(has_open_tanyao=True)))
print(result)
print_hand_result(result)

and it output:

6 han, 30 fu
6 30
12000
[Tanyao, Chinitsu]
{'fu': 20, 'reason': 'base'}
{'fu': 2, 'reason': 'pair_wait'}

All Green should not be optimized:

# small optimization, try to detect yaku with pon required sets only if we have pon sets in hand
if len(pon_sets):

if self.config.yaku.ryuisou.is_condition_met(hand):
hand_yaku.append(self.config.yaku.ryuisou)