MahjongRepository / mahjong

Implementation of riichi mahjong related stuff (hand cost, shanten, agari end, etc.)
MIT License
377 stars 38 forks source link

Problem of All Green #20

Closed paulzzh closed 4 years ago

paulzzh commented 4 years ago

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: https://github.com/MahjongRepository/mahjong/blob/cab4c6c404ab98ff75c716a556ee48dd31dab3cf/mahjong/hand_calculating/hand.py#L204-L205 https://github.com/MahjongRepository/mahjong/blob/cab4c6c404ab98ff75c716a556ee48dd31dab3cf/mahjong/hand_calculating/hand.py#L264-L265