예제 #1
0
파일: state.py 프로젝트: acmnovice/guandan
 def notify_begin(self):
     """
     游戏开始阶段,告知每位玩家的手牌情况
     形如下所表示的JSON:
     {
         "type": "notify",
         "stage": "beginning",
         "handCard": ['S2', 'S2'],
         "myPos": 1,
     }
     请仅在对应的JSON格式下访问对应的实例属性,若此时访问其他属性则很有可能是之前处理时未更新的实例属性,不具有准确性。
     """
     # TODO: 选手可自行做出其他处理
     Strategy.SetBeginning(self._myPos, self._handCards)
     self._greaterPos = -1
     self._greaterAction = None
     print("游戏开始, 我是{}号位,手牌:{}".format(self._myPos, self._handCards))
예제 #2
0
        if (bestPlay == []):
            bestPlay = {'action': 'PASS', 'type': 'PASS', 'rank': 'PASS'}
        #print("bestplay:", bestPlay, "maxvalue", maxValue)
        return bestPlay

    def Play(self, handCards, curRank):
        self.FreePlay(handCards, curRank)


#hand_cards = [[1, '3'], [3, '3'], [2, '5'], [3, '5'], [0, '6'], [2, '6'], [0, '7'], [2, '7'], [2, '7'], [0, '7'], [1, '8'], [2, '8'], [3, '9'], [1, '10'], [2, 'J'], [3, 'J'], [1, 'Q'], [2, 'Q'], [3, 'K'], [0, 'K'], [0, 'K'], [2, 'A'], [0, 'A'], [1, '2'], [0, '2'], [0, 'JOKER'], [0, 'JOKER']]
#cards = ['H2', 'C2', 'D3', 'S4', 'H4', 'C5', 'C5', 'S6', 'D6', 'H8', 'D8', 'S9', 'H9', 'ST', 'CT', 'SJ', 'CJ', 'DJ', 'HQ', 'DQ', 'SK', 'SA', 'HA', 'H7', 'D7', 'SB', 'HR']
#formerAction = {"action": ['H5', 'C5'], "type": 'Pair', 'rank': '5'}
#print(PlayCard().FreePlay(cards,'2'))
#print(PlayCard().RestrictedPlay(hand_cards, formerAction))
'''tic = time.time()

cards =  ['H2', 'D2', 'H3', 'H3', 'C3', 'C3', 'C4', 'C4', 'H5', 'H8', 'ST', 'ST', 'HT', 'DT', 'SJ', 'HJ', 'CJ', 'SA', 'HA', 'DA']
Strategy.SetBeginning(0, cards)
Strategy.curRank = '9'
Strategy.restHandsCount=[27, 27, 10, 27]
Strategy.roundStage = 'ending'

Strategy.UpdatePlay(2, ['TwoTrips', 'Q', ['SQ', 'SQ', 'DQ', 'SK', 'SK', 'DK']], 2, ['TwoTrips', 'Q', ['SQ', 'SQ', 'DQ', 'SK', 'SK', 'DK']])

print(PlayCard().RestrictedPlay(cards,{'action':['SQ', 'SQ', 'DQ', 'SK', 'SK', 'DK'], 'type': 'TwoTrips', 'rank': '9'}, '9'))
#print("RV:", Strategy.restrictedActionRV[('Single','R')])
#Strategy.UpdatePlay(1, None, 1, None)
#print(PlayCard().FreePlay(cards, '9'))

toc = time.time()