Beispiel #1
0
 def setRonHand(self,ronPai,i):
     """
     (int,int) int -> [[(int,int)]]
     i: which form does the ronPai fit
     return breakdown of Ron hand
     """
     b = breakdown(self.hand,self.getOpenHand())
     target_form = b[i][:]
     # 孤张
     for mianzi in target_form:
         if len(mianzi) == 1:
             mianzi.append(ronPai)
             self.ronHand = target_form
             return
         # is_seq
         if len(mianzi) == 2 and has_seq2(mianzi):
             mianzi.append(ronPai)
             mianzi.sort()
             self.ronHand = target_form
             return
         else:
             continue
     # both are pairs
     for mianzi in target_form:
         if len(mianzi) == 2 and has_pair(mianzi):
             if mianzi[0][0] == ronPai[0]:
                 mianzi.append(ronPai)
                 self.ronHand = target_form
                 return 
Beispiel #2
0
    def askRiichi(self):
        if self.isRiichi:
            return False
        if self.openHand["chi"] or self.openHand["pon"] or self.openHand[
                "minKang"]:
            return False
        cutpais = []
        for pai in self.hand:
            hand = self.hand.copy()
            hand.remove(pai)
            if breakdown(hand, self.getOpenHand()) != []:
                cutpais.append(pai)

        if cutpais != []:
            # interaction
            i = int(
                self.inputS(
                    "You can 立直! If you Do not want to 立直 Please press '0'\n Which Pai do you want to cut? (1~) \n"
                    + Pai.showHand(cutpais) + ": "))
            if i == 0:
                self.isRiichi = False
            else:
                self.isRiichi = True
                self.riichipai = cutpais[i - 1]
            return self.isRiichi
Beispiel #3
0
 def askRiichi(self):
     self.isRiichi = False
     if breakdown(self.hand, self.getOpenHand()) != []:
         # interaction
         i = input(
             "You can riichi! press space to riichi, other key to abort")
         if i == " ":
             self.isRiichi = True
             return True
     return False
Beispiel #4
0
 def checkWait(self):
     """
     [[Int]]
     return a list of list of tenpai
     """
     b = breakdown(self.hand,self.getOpenHand())
     ten = [[] for i in range(len(b))]
     seq2_count = 0
     # find all ten
     for i, possibility in enumerate(b):
         for form in possibility:
             if len(form) == 2:
                 if has_seq2(form):
                     seq2_count += 1
                     a = Pai.previous(form[0]) 
                     if a is not None: ten[i].append(a)
                     b = Pai.next(form[1])
                     if b is not None: ten[i].append(b)
                 if has_pair(form) and seq2_count == 0:
                     ten[i].append(Pai.same(form[0]))
             if len(form) == 1:
                 ten[i].append(Pai.same(form[0]))
     return ten
def JapanRon(player):
    ifzhuang = player.ifzhuang
    if (ifzhuang):
        ron = Rondong()
    else:
        ron = Ronxian()
    hand = player.ronHand
    openHand = player.getOpenHand()
    changfeng = player.changfeng
    zifeng = player.zifeng
    lichi = player.isRiichi
    beforehand = util.breakdown(player.hand, openHand)
    hepai = player.draw
    tumo = player.tumo
    if (if_mq(openHand)):
        #Player 先判断门前清番数
        #双倍役满机会(目前暂时认为役满即为最大分值,不支持双倍役满翻番)
        if (czjiulianbaodeng(beforehand)):
            ron.addfan(13)
            ron.setJudgeRon("纯正九莲宝灯")
            ron.setallup()
            return ron
        #直接役满机会 此时可以直接return
        if (sianke(hand)):
            ron.addfan(13)
            ron.setJudgeRon("四暗刻")
            ron.setallup()
            return ron
        if (kokusi13machi(hand)):
            ron.addfan(13)
            ron.setJudgeRon("国士无双")
            ron.setallup()
            return ron
        if (jiulianbaodeng(hand)):
            ron.addfan(13)
            ron.setJudgeRon("九莲宝灯")
            ron.setallup()
            return ron
        #三番役机会
        if (erbeikou(hand)):
            ron.addfan(3)
            ron.setJudgeRon("二杯口")
        #二番役机会
        if (chitoi(hand)):
            ron.addfan(2)
            ron.setJudgeRon("七对子")
        #一番役机会
        if (yibeikou(hand)):
            ron.addfan(1)
            ron.setJudgeRon("一杯口")
        if (pinghe(beforehand, hand, hepai, zifeng, changfeng)):
            ron.addfan(1)
            ron.setJudgeRon("平和")
        if (lichi):
            ron.addfan(1)
            ron.setJudgeRon("立直")
        if (tumo):
            ron.addfan(1)
            ron.setJudgeRon("门前清自摸和")
    #所有牌型均需要判断非门前清的情况
    #双倍役满机会(目前暂时认为役满即为最大分值,不支持双倍役满翻番)
    if (dasixi(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("大四喜")
        ron.setallup()
        return ron
    #役满机会
    if (dasanyuan(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("大三元")
        ron.setallup()
        return ron
    if (ziyise(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("字一色")
        ron.setallup()
        return ron
    if (lvyise(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("绿一色")
        ron.setallup()
        return ron
    if (qinglaotou(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("清老头")
        ron.setallup()
        return ron
    if (xiaosixi(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("小四喜")
        ron.setallup()
        return ron
    if (sigangzi(hand, openHand)):
        ron.addfan(13)
        ron.setJudgeRon("四杠子")
        ron.setallup()
        return ron
    #六番机会
    if (qingyise(hand, openHand)):
        ron.addfan(6)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("清一色")
    #三番机会
    if (cqdyj(hand, openHand)):
        ron.addfan(3)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("纯全带幺九")
    #是混一色的牌不可以是清一色
    if (hunyise(hand, openHand) and not qingyise(hand, openHand)):
        ron.addfan(3)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("混一色")
    #二番机会
    if (sansetk(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("三色同刻")
    if (sangangzi(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("三杠子")
    if (piao(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("对对和")
    if (sananke(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("三暗刻")
    if (xiaosanyuan(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("小三元")
    if (hunlaotou(hand, openHand)):
        ron.addfan(2)
        ron.setJudgeRon("混老头")
    if (hqdyj(hand, openHand)):
        ron.addfan(2)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("混全带幺九")
    if (yiqiguantong(hand, openHand)):
        ron.addfan(2)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("一气贯通")
    if (sansets(hand, openHand)):
        ron.addfan(2)
        #副露减番
        if (not if_mq(openHand)):
            ron.minusfan()
        ron.setJudgeRon("三色同顺")
    #一番机会
    if (noyaojiu(hand, openHand)):
        ron.addfan(1)
        ron.setJudgeRon("断幺九")
    if (is_zifeng(hand, openHand, zifeng)):
        ron.addfan(1)
        ron.setJudgeRon("自风")
    if (is_changfeng(hand, openHand, changfeng)):
        ron.addfan(1)
        ron.setJudgeRon("场风")
    if (sanyuan_fa(hand, openHand)):
        ron.addfan(1)
        ron.setJudgeRon("役牌 发")
    if (sanyuan_bai(hand, openHand)):
        ron.addfan(1)
        ron.setJudgeRon("役牌 白")
    if (sanyuan_zhong(hand, openHand)):
        ron.addfan(1)
        ron.setJudgeRon("役牌 中")
    ron.calcultateFu(hand, openHand, beforehand, tumo, hepai, zifeng,
                     changfeng)
    ron.setallup()
    return ron