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

1from game.ai.defence.yaku_analyzer.yaku_analyzer import YakuAnalyzer 

2from game.ai.helpers.defence import TileDanger 

3from mahjong.utils import is_honor 

4 

5 

6class AtodzukeAnalyzer(YakuAnalyzer): 

7 id = "atodzuke_yakuhai" 

8 

9 def __init__(self, enemy): 

10 self.enemy = enemy 

11 

12 def serialize(self): 

13 return {"id": self.id} 

14 

15 # we must check atodzuke after all other yaku and only if there are no other yaku 

16 # so activation check is on the caller's side 

17 def is_yaku_active(self): 

18 return True 

19 

20 def melds_han(self): 

21 return 1 

22 

23 def get_safe_tiles_34(self): 

24 safe_tiles = [] 

25 for x in range(0, 34): 

26 if not is_honor(x): 

27 safe_tiles.append(x) 

28 elif not self.enemy.valued_honors.count(x): 

29 safe_tiles.append(x) 

30 

31 return safe_tiles 

32 

33 def get_bonus_danger(self, tile_136, number_of_revealed_tiles): 

34 bonus_danger = [] 

35 tile_34 = tile_136 // 4 

36 number_of_yakuhai = self.enemy.valued_honors.count(tile_34) 

37 

38 if number_of_yakuhai > 0 and number_of_revealed_tiles < 3: 

39 bonus_danger.append(TileDanger.ATODZUKE_YAKUHAI_HONOR_BONUS_DANGER) 

40 

41 return bonus_danger 

42 

43 def is_absorbed(self, possible_yaku, tile_34=None): 

44 return len(possible_yaku) > 1