Exemplo n.º 1
0
def run():

    from pychu.tlogic.tcard_names import generate_deck
    from pychu.tstudies import fullhouse
    from pychu.tstudies import straights, bombs

    deck = generate_deck()
    print(straights.street_my_hand(deck))
    print(straights.street_any_hand(deck))
    print(straights.street_any_hand(deck, ph=True))
    print(fullhouse.full_house_myhand(deck))
    print(fullhouse.full_house_myhand(deck, ph=True))
    bombs.bomb(deck)
Exemplo n.º 2
0
    def __init__(self, extplayers: List[TPlayer]):
        if len(extplayers) != 4:
            raise ValueError("4 Players expected!")
        self.players: List[TPlayer] = []
        self.card_log: List[Dict[int, Set[Card]]] = []
        self.extplayers = extplayers
        deck = generate_deck()
        shuffled_deck = r.sample(deck, 56)
        self.players: List[TPlayerProxy] = []

        for s in range(4):
            oCards = shuffled_deck[s * 14:(s + 1) * 14]
            self.players.append(TPlayerProxy(s, oCards))

        for i, player in enumerate(extplayers):
            self.players[i].register(player)
Exemplo n.º 3
0
    async def start(self):
        deck = generate_deck()
        shuffled_deck = r.sample(deck, 56)
        for s in range(4):
            oCards = shuffled_deck[s * 14:(s + 1) * 14]
            res = await self.players[s].dist_cards(oCards, s)

        player_number = self.start_player()

        while self.active_players > 1:  # nplayers > 1
            player_number, cards = await self.turn(player_number, 0)
            self.logEventParams(player_number, TEventType.Take, data=cards)
            self.card_log += cards

        print(self.show_cards())

        return self.card_log
Exemplo n.º 4
0

def bomb(deck):
    k = 10000
    handbombs = 0
    anybombs = 0
    for i in range(k):
        shuffled_deck = r.sample(deck, 56)
        bAnybombs = False
        for s in range(4):
            cards = shuffled_deck[s * 14:(s + 1) * 14]
            cards.sort(key=lambda x: x.height)
            bombs = find_bombs(cards)
            # if bombs: print (bombs)
            bAnybombs = bAnybombs or bombs
            # This might be wrong
            if s == 0:
                if bombs: handbombs += 1
        if bAnybombs: anybombs += 1

    out = ""
    out += str.format("Handbombe: {}\n", handbombs / float(k))
    out += str.format("AnyBombs: {}\n", anybombs / float(k))
    return out


if __name__ == '__main__':
    deck = generate_deck()
    out = bomb(deck)
    print(out)