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.strategies_v2.main import BaseStrategy 

2 

3 

4class FormalTempaiStrategy(BaseStrategy): 

5 def should_activate_strategy(self, tiles_136, meld_tile=None): 

6 """ 

7 When we get closer to the end of the round, we start to consider 

8 going for formal tempai. 

9 """ 

10 

11 result = super(FormalTempaiStrategy, self).should_activate_strategy(tiles_136) 

12 if not result: 

13 return False 

14 

15 # if we already in tempai, we don't need this strategy 

16 if self.player.in_tempai: 

17 return False 

18 

19 # it's too early to go for formal tempai before 11th turn 

20 if self.player.round_step < 11: 

21 return False 

22 

23 # it's 11th turn or later and we still have 3 shanten or more, 

24 # let's try to go for formal tempai at least 

25 if self.player.ai.shanten >= 3: 

26 return True 

27 

28 if self.player.ai.shanten == 2: 

29 if self.dora_count_total < 2: 

30 # having 0 or 1 dora and 2 shanten, let's go for formal tempai 

31 # starting from 11th turn 

32 return True 

33 # having 2 or more doras and 2 shanten, let's go for formal 

34 # tempai starting from 12th turn 

35 return self.player.round_step >= 12 

36 

37 # for 1 shanten we check number of doras and ukeire to determine 

38 # correct time to go for formal tempai 

39 if self.player.ai.shanten == 1: 

40 if self.dora_count_total == 0: 

41 if self.player.ai.ukeire <= 16: 

42 return True 

43 

44 if self.player.ai.ukeire <= 28: 

45 return self.player.round_step >= 12 

46 

47 return self.player.round_step >= 13 

48 

49 if self.dora_count_total == 1: 

50 if self.player.ai.ukeire <= 16: 

51 return self.player.round_step >= 12 

52 

53 if self.player.ai.ukeire <= 28: 

54 return self.player.round_step >= 13 

55 

56 return self.player.round_step >= 14 

57 

58 if self.player.ai.ukeire <= 16: 

59 return self.player.round_step >= 13 

60 

61 return self.player.round_step >= 14 

62 

63 # we actually never reach here 

64 return False 

65 

66 def is_tile_suitable(self, tile): 

67 """ 

68 All tiles are suitable for formal tempai. 

69 :param tile: 136 tiles format 

70 :return: True 

71 """ 

72 return True