Closed Dilant closed 3 years ago
Thank you for the fix. While you are here, can you please change error keys to something readable by human? I wanted to do that before.
Like NWT
-> no_winning_tile_in_hand
.
Also, before submitting PR you can check all linter errors with commands:
make format
make lint
make tests
Thank you for the fix. While you are here, can you please change error keys to something readable by human? I wanted to do that before. Like
NWT
->no_winning_tile_in_hand
Sure, I'll do that 😃
Also, before submitting PR you can check all linter errors with commands
I forgot it and sorry about that... Checked just now, and test cases related to these (maybe breaking) changes will be fixed, e.g.:
234456m66p12344s 4s [Tsumo, Haitei]
Yaku Details
Menzen Tsumo: 1 Han
Haitei Raoyue: 1 Han
Total: 2 Han
Fu Details
Base Fu: 20 Fu
Simple Closed Triplet: 4 Fu
Self Draw: 2 Fu
Total: 30 Fu
def test_is_haitei(self):
hand = HandCalculator()
tiles = self._string_to_136_array(sou="123444", man="234456", pin="66")
win_tile = self._string_to_136_tile(sou="4")
- result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_haitei=True))
+ result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_tsumo=True, is_haitei=True))
self.assertEqual(result.error, None)
- self.assertEqual(result.han, 1)
- self.assertEqual(result.fu, 40)
- self.assertEqual(len(result.yaku), 1)
+ self.assertEqual(result.han, 2)
+ self.assertEqual(result.fu, 30)
+ self.assertEqual(len(result.yaku), 2)
Also, if possible, I'll try to add a unit test for these new error keys.
Thanks a lot!
change error keys to something readable by human check all linter errors test cases related to these (maybe breaking) changes will be fixed add a unit test for these new error keys
All done! 😆
Thank you for these changes.
I didn't get yet why old tests were changed, since these new fixes shouldn't affect them.
In next 1-2 days I will check it detailed and will merge this PR.
I didn't get yet why old tests were changed, since these new fixes shouldn't affect them.
Here's the thing:
is_tsumo=True (False)
are explicitly set for yakus that must (must not) be declared with tsumo. This will change the results, e.g. menzen tsumo
might be included, and 40 fu turns to be 30 fu. For example: # haitei must be tsumo
- result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_haitei=True))
+ result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_tsumo=True, is_haitei=True))
# houtei must not be tsumo
- result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_houtei=True))
+ result = hand.estimate_hand_value(tiles, win_tile, config=self._make_hand_config(is_tsumo=False, is_houtei=True))
chankan
and rinshan
are modified to fit actual situations
chankan
definitely robs a tile not in handrinshan
should call a kan meld (and then tsumo)# chankan: how can others make a shouminkan of "4s"?
tiles = self._string_to_136_array(sou="123444", man="234456", pin="66")
- win_tile = self._string_to_136_tile(sou="4")
+ win_tile = self._string_to_136_tile(sou="1")
# rinshan: you should call a kan (and then tsumo)
- tiles = self._string_to_136_array(sou="123444", man="234456", pin="66")
- win_tile = self._string_to_136_tile(sou="4")
+ tiles = self._string_to_136_array(sou="1234444", man="234456", pin="66")
+ win_tile = self._string_to_136_tile(sou="1")
+ melds = [self._make_meld(Meld.KAN, is_open=False, sou="4444")]
suukantsu & tsuisou & daisushi & suuankou tanki
# 1112223334445z 5z tenhou & tsuisou & daisushi & suuankou tanki
# must be tsumo because of tenhou
self.assertEqual(result.cost["main"], 96000)
self.assertEqual(result.cost["additional"], 48000)
# 5z -11-z -22-z -33-z -44-z 5z suukantsu & tsuisou & daisushi & suuankou tanki
# can be tsumo or ron (here's ron)
self.assertEqual(result.cost["main"], 192000)
open_hand_riichi
and ippatsu_without_riichi
are moved from tests_yaku_calculation.py
to tests_hand_response_error.py
Yep, figured it out. Thank you for the contribution! Do you need new version with these fixes released in pip?
Do you need new version with these fixes released in pip?
Maybe not now. I think it's better to wait for Japanese translations, and then everything is ready.
I added a lot of possible error condition handlers in the HandCalculator class. And:
Tenhou
,Chiihou
,Renhou
are still not considered (They conflict with so many options and yakus)n倍役满中译是真的皮