Esempio n. 1
0
def caculcateWinRateBy(deck, players, totalNum=2500):
    showList = deck.showList.copy()
    cardList = deck.inDeck.copy()
    winNum = [0 for i in players]

    totalResult = []

    if len(showList) >= 3:
        totalResult = _generateProbabilityGroupResult(cardList)
    else:
        dealNum = 5 - len(showList)
        totalResult = _generateRandomGroupResult(cardList, totalNum, dealNum)

    for cards in totalResult:
        cards.extend(showList)
        pv = [0 for i in players]
        for index, player in enumerate(players):
            temp = SevenCard.fromCardArray(cards, player.hands)
            temp.caculateAll()
            if temp.value > pv[index]:
                pv[index] = temp.value

        m = max(pv)
        for index, val in enumerate(pv):
            if val == m:
                winNum[index] += 1

    totalPv = 0
    for index, num in enumerate(winNum):
        totalPv += num
    res = []
    for index, num in enumerate(winNum):
        players[index].winRate = num / totalPv
        res.append(num / totalPv)
    return res
Esempio n. 2
0
 def makePlayersHandsValue(self):
     for p in self.livingPlayers:
         seven = SevenCard.fromCardArray(self.deck.showList, p.hands)
         seven.caculateAll()
         p.handsValue = seven.value