def __init__(self, players): self.deck = Deck() self.deck.fillDeck() self.playing = False self.actions = {} self.players = players self.nextPlayer = iter(self.nextPlayerIterFunc()) self.currentPlayer = next(self.nextPlayer)
def __init__(self): self.players = Players() self.players.createPlayer('** Dealer **', Player.PlayerType[2]) self.deck = Deck() self.tableMax = 10 self.tableMin = 1 self.players.createPlayer('Human Player', Player.PlayerType[0], 100) self.players.createPlayer('CPU Player 1', Player.PlayerType[1], 100)
def generateAllFullHands(verbose=False): previousPercentage = 0. deck = Deck() fhs = [0] * 2598960 for i, cards in enumerate(combinations(deck, 5)): fhs[i] = FullHand(*cards) if verbose: percentage = round(i / 2598960, 3) if percentage > previousPercentage: previousPercentage = percentage print("{:.1f}%".format(percentage * 100)) return fhs
def __init__(self, players): super(Stress, self).__init__(players) self.playFlag = False self.currentPlayer = None self.skipNextTurn = False # Discard pile used to pick up with cheat moves self.played = Deck() # Dictionary to define possible actions to take self.actions = { "{players}" : self.getPlayers, "{start}" : self.playStress, "{play}" : self.playCards, "{hand}" : self.showHand, "{help}" : self.getHelp }
def __init__(self, table=None): self.winners = [] self.alreadyShowedGameRound = False self.table = table self.deck = Deck() self.gameRound = GameRound.PREFLOP self.maxBet = 0 self.currentPlayer = None for player in self.table.players: player.game = self self.table.board = Board() self.table.board.game = self
def __init__(self, noplayers, initial_stake): self.players = [] self.dealer = Player("Dealer", 10000) self.deck = Deck() self.deck.shuffle() cards = self.deck.deal(2) dealerHand = Hand() dealerHand.add_cards(cards) self.dealer.initialHand(dealerHand) for i in range(0, noplayers): player = Player("Player" + str(i + 1), initial_stake) cards = self.deck.deal(2) playerHand = Hand() playerHand.add_cards(cards) player.initialHand(playerHand) self.players.append(player) print_all_hands(self.dealer, self.players) self.play_rounds()
def __init__(self, players): super(Cheat, self).__init__(players) self.playFlag = False self.cheatcaller = None self.nextRank = iter(self.nextRankIterFunc()) self.currentPlayer = None self.currentRank = None # Discard pile used to pick up with cheat moves self.discard = Deck() # Buffer deck to hold cards while cheaters may cheat self.bufferDeck = CardStack() # Dictionary to define possible actions to take self.actions = { "{players}": self.getPlayers, "{start}": self.playCheat, "{play}": self.playCards, "{hand}": self.showHand, "{cheat}": self.callCheat, "{help}": self.getHelp }
def __init__(self, players): super(BigTwo, self).__init__(players) self.playFlag = False self.cheatcaller = None self.currentNumCards = 0 self.nextRank = 0 self.currentPlayer = None self.currentRank = None self.endTrick = True self.passCount = 0 # Discard pile used to pick up with cheat moves self.discard = Deck() # Buffer deck to hold cards while cheaters may cheat self.bufferDeck = CardStack() # Dictionary to define possible actions to take self.actions = { "{players}": self.getPlayers, "{start}": self.playBigTwo, "{play}": self.playCards, "{hand}": self.showHand, "{pass}": self.callPass, "{help}": self.getHelp }
from Cards import CardStack, Deck unplayedDeck = Deck() playedDeck = Deck() playedDeck.changeVisibility() # stuff outside this class should be in machine, just used it for testing class Player(object): """Represents a player object""" def __init__(self, name): super().__init__() self.name = name self.hand = CardStack() self.handSize = 0 def getHand(self): return str(self.hand.cards) def draw(self, num=1): if unplayedDeck.isEmpty(): saveCard = playedDeck.draw() while not playedDeck.isEmpty(): unplayedDeck.addToDeck(playedDeck.draw()) unplayedDeck.shuffle() playedDeck.addToDeck(saveCard) for i in range(num): self.hand.cards.append(unplayedDeck.draw()) self.handSize += 1 def takeAll(self):
def setup_deck(self): self.dealer_deck = Deck() self.cards_dealt = Deck() self.dealer_deck.fresh_deck(suits, ranks) self.dealer_deck.shuffle()
from itertools import combinations from multiprocessing import Lock, Process, Array, Value from time import time from scipy.special import comb from Cards import Cards, Deck, FullHand from Enums import GameRound from Player import Player from Table import Table showdownCombinations = combinations(Deck(), 9) numberOfCombinations = comb(52, 9, exact=True, repetition=False) chunks = [] chunkSize = 100 def generateAllFullHands(verbose=False): previousPercentage = 0. deck = Deck() fhs = [0] * 2598960 for i, cards in enumerate(combinations(deck, 5)): fhs[i] = FullHand(*cards) if verbose: percentage = round(i / 2598960, 3) if percentage > previousPercentage: previousPercentage = percentage print("{:.1f}%".format(percentage * 100)) return fhs
from Cards import Card, Deck from Game21 import Game21 f = open('data.txt', 'w') count = 1000 f.write('A list of {} Random 21 Hands\r\n'.format(count)) deck = Deck() game21 = Game21() for x in range(1, count): deck.cleanShuffle() cards = deck.dealCard(2) while (game21.handValue(cards) < 21): cards.append(deck.dealCard(1).pop()) cardsString = '' for c in cards: cardsString += '{}{} '.format(c.rank, c.suit) f.write('{}\r\n'.format(cardsString)) print("{}% done".format((float(x + 1) / float(count)) * 100)) f.close()
print("How many players?") while num_players < 2: num_players = int(input()) if num_players == -1: quit() if num_players < 2: print("You need at least 2 players to play s******d! Try again...") for i in range(num_players): print("Enter Name for Player",i+1,":") name = input() players.append(ShitheadPlayer(name)) num_decks = 1+num_players//3 playing_deck = Deck(num_decks) playing_deck.shuffle() discard_pile = [] # Deal Cards for place in ['fd','fu','hand']: for i in range(3): for j in range(num_players): players[j].add_card(playing_deck.pop(),place) # Game player_ind = 0 direction = 1
def testDeckRemove(self): deck = Deck() card23 = Card(2, 3) deck.remove(card23)