Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import hashlib 

2import marshal 

3from typing import List 

4 

5from utils.decisions_logger import MeldPrint 

6 

7 

8def build_shanten_cache_key(tiles_34: List[int], use_chiitoitsu: bool): 

9 prepared_array = tiles_34 + [int(use_chiitoitsu)] 

10 return hashlib.md5(marshal.dumps(prepared_array)).hexdigest() 

11 

12 

13def build_estimate_hand_value_cache_key( 

14 tiles_136: List[int], 

15 is_riichi: bool, 

16 is_tsumo: bool, 

17 melds: List[MeldPrint], 

18 dora_indicators: List[int], 

19 count_of_riichi_sticks: int, 

20 count_of_honba_sticks: int, 

21 additional_han: int, 

22 is_rinshan: bool, 

23 is_chankan: bool, 

24): 

25 prepared_array = ( 

26 tiles_136 

27 + [is_tsumo and 1 or 0] 

28 + [is_riichi and 1 or 0] 

29 + (melds and [x.tiles for x in melds] or []) 

30 + dora_indicators 

31 + [count_of_riichi_sticks] 

32 + [count_of_honba_sticks] 

33 + [additional_han] 

34 + [is_rinshan and 1 or 0] 

35 + [is_chankan and 1 or 0] 

36 ) 

37 return hashlib.md5(marshal.dumps(prepared_array)).hexdigest()