def hand_rating(hole_card_list, comm_card_list, suit_comm_list, suit_hole_list):
    print ''
    print 'hole card list = ', hole_card_list
    print 'comm card list = ', comm_card_list
    print ''
    num_better_hands = 0
    my_result = hand.hand(hole_card_list, comm_card_list, suit_comm_list, suit_hole_list)
    hole_card_list = [0]*13
    suit_hole_list = [0]*4
    summ = 0
    for i in range(52):
        for j in range(i+1, 52):
            hole_card_list[i%13] += 1           #need to prevent overcounting
            hole_card_list[j%13] += 1
            suit_hole_list[i/13] += 1
            suit_hole_list[j/13] += 1


            opponent_result = hand.hand(hole_card_list, comm_card_list, suit_comm_list, suit_hole_list)

                     
            if opponent_result > my_result:
                num_better_hands += 1

                
            hole_card_list = [0]*13
            suit_hole_list = [0]*4


    print 'rating = ', 1 - num_better_hands/1326.0, 'my result = ', my_result
    return 1 - num_better_hands/1326.0      #there are 1326 possible hands
예제 #2
0
def multiprocess_simulator(num_deck, batch, queue):
    '''Puts the results of hand in a queue

    Parameters:
    num_deck (int): total number of decks required
    batch (int): total number of batches to run
    queue (multiprocessing.queues.Queue): queue to put the hand results in
    '''
    player_won = 0
    tie = 0
    dealer_won = 0

    for _ in range(0, batch):

        outcome = hand(deck(num_deck))

        if outcome == 1:
            player_won += 1

        if outcome == 0:
            tie += 1

        if outcome == -1:
            dealer_won += 1

    queue.put([player_won, tie, dealer_won])
예제 #3
0
    def __init__(self, ID, dealer):
        self.ID = ID
        self.dealer = dealer
        self.card1 = None
        self.card2 = None
        self.hand = hand(self)

        self.stack = 500
        self.recordOfPastGames = []
        self.gameData = [
            None, None, None, None, None, None, None, None, None, None, None,
            None
        ]
        self.gameRound = 12

        #Indecies for the gameData array
        self.PREFLOP_OPPONENT_BET = 0
        self.PREFLOP_HAND_SCORE = 1

        self.FLOP_OPPONENT_BET = 2
        self.FLOP_HAND_SCORE = 3
        self.FLOP_BOARD_SCORE = 4

        self.TURN_OPPONENT_BET = 5
        self.TURN_HAND_SCORE = 6
        self.TURN_BOARD_SCORE = 7

        self.RIVER_OPPONENT_BET = 8
        self.RIVER_HAND_SCORE = 9
        self.RIVER_BOARD_SCORE = 10

        self.RESULT_WIN = 11
예제 #4
0
 def __init__(self, ifHumanPlayer = False):
     'handOfCards: a "hand" of cards; ifHumanPlayer: whether this player is human'
     self.handOfCards = hand()
     self.score = 0
     self.allPlayers=[]
     self.playerNum=-1
     self.setMode(ifHumanPlayer)
예제 #5
0
def init():

    h = hand(1)
    J = 11
    Q = 12
    K = 13
    A = 14

    testHand = []

    # testHand.append(card(5, "5", "dmd"))
    # testHand.append(card(5, "5", "hrt"))
    # testHand.append(card(4, "4", "clb"))
    # testHand.append(card(2, "2", "dmd"))
    # testHand.append(card(3, "3", "spd"))
    # testHand.append(card(Q, "Q", "c;b"))
    # testHand.append(card(A, "A", "hrt"))

    # testHand.append(card(3, "5", "dmd"))
    # testHand.append(card(3, "5", "hrt"))
    # testHand.append(card(10, "4", "clb"))
    # testHand.append(card(9, "2", "dmd"))
    # testHand.append(card(10, "3", "spd"))
    # testHand.append(card(Q, "Q", "c;b"))
    # testHand.append(card(3, "A", "hrt"))

    # h.updateHand(testHand)
    # print(h.hand_rank, ", ", h.highCard)

    #while True:
    initLog()
    start_table()
예제 #6
0
파일: agent.py 프로젝트: Poolsharky/pokerai
 def __init__(self, ID, dealer, level):
     self.ID = ID
     self.dealer = dealer
     self.card1 = None
     self.card2 = None
     self.hand = hand(self)
     self.stack = 500
     self.level = level
예제 #7
0
def crossover(parents):
    legal = False
    while not legal:
        # pick two random parents
        parent1 = parents[random.randrange(1, len(parents))]
        parent2 = parents[random.randrange(1, len(parents))]
        index = random.randrange(0,4)
        child = hand(parent1.cards[0:index] + parent2.cards[index:5])
        legal = child.checkLegality(child.cards)
    return child
예제 #8
0
def random_test():

    my_deck = deck()
    my_deck.shuffle()

    hands = []
    while my_deck.size >= 5:
        my_hand = hand(my_deck.draw(5))
        hands.append(my_hand)

        print(my_hand)
        print(my_hand.game)
        print('\n')
예제 #9
0
파일: agentai.py 프로젝트: vkhibkin/pokerai
    def __init__(self, ID, dealer):
        self.ID = ID
        self.dealer = dealer
        self.card1 = None
        self.card2 = None
        self.hand = hand(self)

        self.stack = 500
        self.recordOfPastGames = []
        self.gameData = [
            None, None, None, None, None, None, None, None, None, None, None,
            None
        ]
        self.gameRound = 12

        #Indecies for the gameData array
        self.PREFLOP_OPPONENT_BET = 0
        self.PREFLOP_HAND_SCORE = 1

        self.FLOP_OPPONENT_BET = 2
        self.FLOP_HAND_SCORE = 3
        self.FLOP_BOARD_SCORE = 4

        self.TURN_OPPONENT_BET = 5
        self.TURN_HAND_SCORE = 6
        self.TURN_BOARD_SCORE = 7

        self.RIVER_OPPONENT_BET = 8
        self.RIVER_HAND_SCORE = 9
        self.RIVER_BOARD_SCORE = 10

        self.RESULT_WIN = 11

        f = open("agentMemory.csv", "r")
        reader = csv.reader(f)
        for record in reader:
            tempAr = []
            for i in range(0, len(record) - 1):
                tempAr.append(float(record[i]))

            if (record[self.RESULT_WIN] == "False"):
                tempAr.append(False)
            else:
                tempAr.append(True)
            self.recordOfPastGames.append(tempAr)
        f.close()
예제 #10
0
def main():
    # variables to play around with
    populationSize = 200
    generations = 300
    numParents = int(populationSize / 2)

    # STEP 1: Generate population
    population = []
    for i in range(populationSize):
        population.append(hand())

    # loop through generations
    for gen in range(generations):
        # STEP 2: Calculate fitness of each hand and average population fitness
        probabilityList = calculatePopulationFitness(population, populationSize, gen)

        # STEP 3: Select parents for next generation
        # sort in reverse order of fitness
        population.sort(key=lambda hand: hand.fitness, reverse=True)
        # choose parents
        parents = []
        for i in range(numParents):
            # choose random parent, giving weight to their fitness
            newParent = choice(population, p = probabilityList)
            parents.append(newParent)

        # STEP 4: Reproduce with 80% crossover, 10% mutation, and 10% elitism
        # new population becomes the result of reproduction
        # start with no children
        population = []
        # mutation 10% of the time:
        # creating .1 * populationSize children
        for i in range(int(.1 * populationSize)):
            population.append(mutate(parents))

        # elitism 10% of the time:
        for i in range(int(.1 * populationSize) - 1):
            population.append(elitism(parents))

        # crossover 80%
        for i in range(int(.8 * populationSize)):
            population.append(crossover(parents))

    print "Final generation"
    calculatePopulationFitness(population, populationSize, generations)
예제 #11
0
def multiprocess_simulator(num_deck, num_players, batch, queue):

    player_list = []
    total_tie = 0
    total_dealer_won = 0

    for _ in range(0, batch):

        player_won, tie, dealer_won = hand(deck(num_deck), num_players)
        if not player_list:
            player_list = player_won
        else:
            for i, j in enumerate(player_won):
                player_list[i] += j
        total_tie += tie 
        total_dealer_won += dealer_won


    queue.put([player_list, total_tie, total_dealer_won])
예제 #12
0
 def start_game(self):
     #start playing yatzee!
     self.h = hand()
     for i in range(0,13):
         self.view.show_scoreboard(self.scengine)
         self.view.show_hand(self.h)
         self.view.get_input(self.h)
         self.h.roll()
         self.view.show_hand(self.h)
         self.view.get_input(self.h)
         self.h.roll()
         self.view.show_hand(self.h)
         self.view.show_potential_points(self.h, self.scengine)
         self.h.unhold_all()
         self.h.roll()
     self.view.show_scoreboard(self.scengine)
         
         
     
예제 #13
0
def start_game(players):

    table = []
    for count in range(players):
        plr = player(hand(my_deck.draw(5)))
        table.append(plr)

        print(plr, plr.hand.game_cards)

    table = compare_games(table)

    winner = table[0]
    if winner.splitted:
        winner_table = splitted_pot(table)
        print('\nPot splitted!')
        print('Winners:\n')
        for plr in winner_table:
            print('Player: {} - {} - {}'.format(plr.name, plr.hand.game_name,
                                                plr.hand.game_cards))
    else:
        print('\nWinner: {} - {} - {}'.format(winner.name,
                                              winner.hand.game_name,
                                              winner.hand.game_cards))
def sp(e1, e2, e3):
    print "hiii"
    try:
        e.h1 = e1
        e.h2 = e2
        e.h3 = e3

        recog = AppKit.NSSpeechRecognizer.alloc().init()
        recog.setCommands_(
            [u"coffee powder", u"milk", u"sugar", u"Quit the test."])

        recog.setListensInForegroundOnly_(False)
        d = SRDelegate.alloc().init()
        recog.setDelegate_(d)

        if e.t == "coffee powder":
            system("say  -v vicki it is in rack " + str(e.h2))
            hand(1)

        elif e.t == "milk":
            system("say  -v vicki it is in rack " + str(e.h1))
            hand(2)

        elif e.t == "sugar":
            system("say  -v vicki it is in rack " + str(e.h3))
            hand(3)

        else:
            system(
                "say -v vicki What ingrident do you want coffee powder, milk , or sugar "
            )
            print "Listening..."
            recog.startListening()
            runLoop = NSRunLoop.currentRunLoop()
            runLoop.run()

# Now we need to enter the run loop...

    except ValueError:
        print "Try again..."
예제 #15
0
def PlayHand(
):  # Plays a single hand of blackjack -- No real gambling required!

    print()
    print('Starting a new round of Blackjack...')

    gameDeck = deck()  # Deck object shuffles itself upon init...
    playerHand = hand()
    dealerHand = hand()
    playerHit = True
    # dealerHit = True # Currently Unused
    dealerThreshold = random.randint(16, 19)  # Just a fun little logic tweak.

    gameDeck.shuffle()  # Shuffled twice; extra nice...

    print('Dealing two cards each...')
    print()

    print('You are dealt the',
          playerHand.hit(gameDeck))  # I was going to iterate this with a loop
    dealerHand.hit(
        gameDeck
    )  # But I don't think I can show the dealer's top card in a loop

    print('You are dealt the', playerHand.hit(gameDeck))

    print()
    print("Dealer's Top Card Showing:")
    print(
        dealerHand.hit(gameDeck)
    )  # I hope that works; maybe we should use a dedicated 'top card' method?
    print()

    if dealerHand.blackjack():
        print('The Dealer was dealt a Blackjack! Ugh!')
        print("The Dealer's Hand:")
        dealerHand.Print()
        print("Dealer's Hand Value:", dealerHand.value())
        print('Better Luck Next Hand!')
        return False

    while playerHit:
        print('Your Hand:')
        playerHand.Print()
        print("Your Hand's Value:", playerHand.value())
        print()
        if playerHand.blackjack():
            print('Blackjack! It must be your lucky day!')
            return True
        choice = str(input('\a Would you like to Hit, or Stay? (Y/N) '))
        if choice[0].upper() in ('Y', 'H'):
            print()
            print('You hit, drawing the', playerHand.hit(gameDeck))
            print()
            if playerHand.have21():
                print('A Perfect 21! You must feel pretty lucky, huh?')
                playerHand.Print()
                print("Your Hand's Value:", playerHand.value())
                return True
            elif playerHand.bust():
                print('You bust! Sorry, friend. Better luck next time!')
                playerHand.Print()
                print("Your Hand's Value:", playerHand.value())
                return False
        else:
            print()
            playerHit = False
            print("You've chosen to stand at", playerHand.value())
            print()
        if dealerHand.value(
        ) < dealerThreshold:  # It's not fun if you know what the dealer will do.
            print('Dealer hits, drawing the', dealerHand.hit(gameDeck))
            if dealerHand.have21():
                print('The Dealer hit 21! Tough Luck!')
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                return False
            elif dealerHand.bust():
                print('The Dealer went bust! Sweet Revenge!')
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                return True
        else:
            print('The Dealer has chosen to stay...')
        print()
# Complete Turn, Before Standing

    while not playerHit:  # Dealer finishes playing up to final value
        if dealerHand.value() < dealerThreshold:
            print('Dealer hits, drawing the', dealerHand.hit(gameDeck))
            if dealerHand.have21():
                print('The Dealer hit 21! Tough Luck!')
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                return False
            elif dealerHand.bust():
                print('The Dealer went bust! Sweet Revenge!')
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                return True
        else:  # Final Decision Suite
            if dealerHand.value() > playerHand.value():
                print("The Dealer Won. Oh well, them's the breaks...")
                print()
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                print()
                print("Your Hand:")
                playerHand.Print()
                print("Your Hand's Value:", playerHand.value())
                return False

            if dealerHand.value() < playerHand.value():
                print("You beat the dealer! Not too shabby!")
                print()
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                print()
                print("Your Hand:")
                playerHand.Print()
                print("Your Hand's Value:", playerHand.value())
                return True

            if dealerHand.value() == playerHand.value():
                print(
                    "A Tie?! This is why they say 'The House Always Wins'...")
                print()
                print("The Dealer's Hand:")
                dealerHand.Print()
                print("Dealer's Hand Value:", dealerHand.value())
                print()
                print("Your Hand:")
                playerHand.Print()
                print("Your Hand's Value:", playerHand.value())
                return False
        print()


# Complete Turn, After Standing

# I wonder if that's how the Jack of Spades and the Jack of Clubs each lost an eye...
예제 #16
0
 def __init__(self, fileName):
     self.fileName = fileName
     self.hands = []
     self.thisHand = hand()
예제 #17
0
    def parseHands(self):
        for line in open(self.fileName):
            if 'Ignition Hand #' in line:
                #                print line.split('#')[1].split()[0]
                self.hands.append(hand(0))
                self.thisHand = self.hands[-1]
                #self.thisHand.id=int(line.split()[2][1:])
                self.thisHand.id = int(line.split('#')[1].split()[0])
                #                print 'parsing hand #',self.thisHand.id
                self.thisHand.time = line.rstrip()[-8:]
                self.thisHand.date = line[-21:-11]
                self.thisHand.BBsize = float(
                    self.fileName.split('$')[2].split('-')[0])
                self.thisHand.SBsize = float(
                    self.fileName.split('$')[1].split('-')[0])

            self.thisHand.text += line
            #starting stack, players positions, and identify me
            if 'in chips' in line:
                playerIdx = self.getPlayerIdx(line)
                startingStack = float(
                    line[line.index('$') +
                         1:line.index('in chips')]) / self.thisHand.BBsize
                self.thisHand.players[playerIdx].startingStack = startingStack
                if '[ME]' in line:
                    self.thisHand.players[playerIdx].isMe = True
                self.thisHand.players[playerIdx].position = self.getPosition(
                    line)
            #identify hole cards
            if 'Card dealt to a spot' in line:
                if 'Small Blind' in line and self.thisHand.getSB():
                    self.thisHand.getSB().holeCards = self.getHoleCards(line)
                elif 'Big Blind' in line and self.thisHand.getBB():
                    self.thisHand.getBB().holeCards = self.getHoleCards(line)
                elif 'UTG+2' in line and self.thisHand.getUTG2():
                    self.thisHand.getUTG2().holeCards = self.getHoleCards(line)
                elif 'UTG+1' in line and self.thisHand.getUTG1():
                    self.thisHand.getUTG1().holeCards = self.getHoleCards(line)
                elif 'UTG ' in line and self.thisHand.getUTG():
                    self.thisHand.getUTG().holeCards = self.getHoleCards(line)
                elif 'Dealer' in line and self.thisHand.getBTN():
                    self.thisHand.getBTN().holeCards = self.getHoleCards(line)
            if '*** FLOP ***' in line or '*** TURN ***' in line or '*** RIVER ***' in line:
                self.thisHand.streetCounter += 1

            #parse actions
            if self.isActionLine(line):
                self.thisHand.actionCounter += 1

                streets = ['P', 'F', 'T', 'R']
                newAction = streetAction(streets[self.thisHand.streetCounter],
                                         self.thisHand.actionCounter,
                                         self.getAction(line),
                                         self.getAmount(line))
                actionPlayer = self.getPlayer(line)
                actionPlayer.actions.append(newAction)
                actionPlayer.amountWon -= self.getAmount(line)
                #print newAction.order,newAction.street,actionPlayer.position,newAction.action,newAction.amount,actionPlayer.amountWon
            if 'Return uncalled' in line:
                winner = self.getPlayer(line)
                winner.amountWon += self.getAmount(line)
            if 'Hand result' in line:
                self.thisHand.postRakePot += self.getAmount(line)
                winner = self.getPlayer(line)
                winner.amountWon += self.getAmount(line)
                self.thisHand.nWinners += 1
            if 'Total Pot' in line:
                self.thisHand.preRakePot = self.getAmount(line)
                if self.thisHand.getBB():
                    self.thisHand.getBB().amountWon -= 1
                if self.thisHand.getSB():
                    self.thisHand.getSB(
                    ).amountWon -= self.thisHand.SBsize / self.thisHand.BBsize
                for player in self.thisHand.players:
                    if player.amountWon > 0:
                        player.rakePaid += (
                            self.thisHand.preRakePot -
                            self.thisHand.postRakePot) / self.thisHand.nWinners
예제 #18
0
 def test_hand_value_type(self):
     hand_return_value = hand(deck())
     self.assertIsInstance(hand_return_value, int)
예제 #19
0
def PlayHand():
    import deck
    import hand
    prompt = 'H'
    player = hand.hand()
    dealer = hand.hand()

    #new deck
    mazo = deck.deck()

    #Shuffle new deck
    mazo.shuffle()

    #deal two cards to player
    player.hit(mazo)
    player.hit(mazo)
    #deal two cards to dealer and only show the first card
    print("\nThe dealer is showing a", dealer.hit(mazo))
    dealer.hit(mazo)

    #create loop to keep playing if need it
    while prompt == 'H' and not player.bust() and not player.have21():
        print("\nYour hand:\n")
        player.Print()
        print("You have a total of", player.value())
        prompt = input("\nHit (H) or Stand (S): ").upper()
        if prompt == 'H':
            print("\nYou got the", player.hit(mazo))

#Player black jack, stop asking hit or stand
    if player.blackjack():
        print("\nYour hand:\n")
        player.Print()
        print("************")
        print("*Black Jack*")
        print("************")

#Player has 21, stop asking hit or stand
    if player.have21():
        print("\nYour hand:\n")
        player.Print()
        print("You have a total of", player.value())

#Player busted, stop asking hit or stand and return false
    if player.bust():
        print("\nYour hand:\n")
        player.Print()
        print("You have a total of", player.value())
        print("\nYou busted, Dealer wins!")
        return False

#Dealer keep getting cards until it reaches 17
    while dealer.value() < 17:
        dealer.hit(mazo)
    print("\nDealer's hand:\n")
    dealer.Print()
    print("Dealer has a total of", dealer.value(), "\n")

    #Dealer has blackjack wins and return false
    if dealer.blackjack():
        print("Dealer has a Black Jack!")
        print("Dealer wins!")
        return False

#Player has blackjack wins only if dealer doesnt have blackjack
    if player.blackjack():
        print("Blackjack, you win!")
        return True

#dealer is higher or equal than player without bustin, dealer wins
    if player.value() <= dealer.value() and not dealer.bust():
        print("Dealer wins!")
        return False

#player is higher than dealer
    if player.value() > dealer.value():
        print("Player wins!")
        return True
#dealer bust
    if dealer.bust():
        print("Dealer busted, you win!")
        return True
예제 #20
0
 def split(self, currentHand, c1, c2):
     splitHand = hand()
     self.__hands.append(splitHand)
     splitHand.addCard(currentHand.removeCard())
     currentHand.addCard(c1)
     splitHand.addCard(c2)
예제 #21
0
def hand_movement(frame, detection_graph, sess, head):
    hand(frame, detection_graph, sess, head)
예제 #22
0
 def test_hand_value(self):
     hand_return_value = hand(deck())
     self.assertIn(hand_return_value, [1, 0, 1, -1])
예제 #23
0
def cards_test(test=None):
    def mock_highcard():
        return [[
            card('A', 'Hearts', 14),
            card('2', 'Spades', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
            card('5', 'Spades', 3),
        ], 1,
                get_game_name(1)]

    def mock_pair():
        return [[
            card('2', 'Spades', 0),
            card('2', 'Clubs', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
            card('5', 'Spades', 3),
        ], 2,
                get_game_name(2)]

    def mock_twopairs():
        return [[
            card('2', 'Spades', 0),
            card('2', 'Clubs', 0),
            card('3', 'Spades', 1),
            card('3', 'Clubs', 1),
            card('4', 'Spades', 2),
        ], 3,
                get_game_name(3)]

    def mock_three():
        return [[
            card('2', 'Spades', 0),
            card('2', 'Clubs', 0),
            card('2', 'Hearts', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
        ], 4,
                get_game_name(4)]

    def mock_straight():
        return [[
            card('2', 'Spades', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
            card('5', 'Clubs', 3),
            card('6', 'Spades', 4),
        ], 5,
                get_game_name(5)]

    def mock_flush():
        return [[
            card('2', 'Spades', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
            card('5', 'Spades', 3),
            card('A', 'Spades', 14),
        ], 6,
                get_game_name(6)]

    def mock_fullhouse():
        return [[
            card('2', 'Spades', 0),
            card('2', 'Clubs', 0),
            card('3', 'Clubs', 1),
            card('3', 'Spades', 1),
            card('3', 'Hearts', 1),
        ], 7,
                get_game_name(7)]

    def mock_four():
        return [[
            card('2', 'Spades', 0),
            card('2', 'Clubs', 0),
            card('2', 'Diamonds', 0),
            card('2', 'Hearts', 0),
            card('3', 'Spades', 1),
        ], 8,
                get_game_name(8)]

    def mock_street():
        return [[
            card('2', 'Spades', 0),
            card('3', 'Spades', 1),
            card('4', 'Spades', 2),
            card('5', 'Spades', 3),
            card('6', 'Spades', 4),
        ], 9,
                get_game_name(9)]

    def mock_royal():
        return [[
            card('10', 'Spades', 8),
            card('J', 'Spades', 9),
            card('Q', 'Spades', 10),
            card('K', 'Spades', 11),
            card('A', 'Spades', 12),
        ], 10,
                get_game_name(10)]

    test = [
        mock_highcard(),
        mock_pair(),
        mock_twopairs(),
        mock_three(),
        mock_straight(),
        mock_flush(),
        mock_fullhouse(),
        mock_four(),
        mock_street(),
        mock_royal()
    ]

    failed_list = []
    ok_list = []

    for mock in test:
        mock_game = mock[0]
        mock_value = mock[1]
        mock_name = mock[2]
        test_hand = hand(mock[0])
        print('\nTesting {}...'.format(mock_name))
        if test_hand.game_value == mock_value:
            ok_list.append(mock_name)
        else:
            failed_list.append(mock_name)

    print('\n\nFinished test:')
    print('Passed:', ok_list)
    print('Failed', failed_list)
예제 #24
0
파일: main.py 프로젝트: jamesl-10/Blackjack
# Creates all the cards, then puts into deck
for i in range(len(ranks)):
    for j in range(len(suits)):
        c = card(suits[j], ranks[i])
        deckOfCards.addCard(c)

# Shuffles deck
deckOfCards.shuffle()

print(
    "Welcome to Blackjack! The objective of the game is to draw cards until you get cards with values as close to 21 as possible!"
)

while True:
    # Creates hands
    user = hand()
    computer = hand()

    # Initial deal
    # Player dealt two cards
    for i in range(2):
        user.addCard(deckOfCards.drawCard())

    # Computer dealt one card
    # The other one is 'face down', (not dealt yet)
    computer.addCard(deckOfCards.drawCard())

    # Creates player
    p1 = player(user)

    # Shows dealer's card
예제 #25
0
                nah = 1
                lr = lr + 1
                if (lr > 1):
                    print "look right"
                    system("say look right")
                    lr = 0

# print nah

            if nah == 0 and yt == 1 and gt == 1 and rt == 1:

                text = sp(e.coffee, e.milk, e.sugar)
                system("say  -v vicki " + text)
                if (text == "coffee powder"):
                    system("say  -v vicki it is in rack " + str(e.coffee))
                    hand(1)
                elif (text == "milk"):
                    system("say  -v vicki it is in rack " + str(e.milk))
                    hand(2)
                elif (text == "sugar"):
                    system("say  -v vicki it is in rack " + str(e.sugar))
                    hand(3)
                else:
                    system("say  -v vicki not in rack ")

                s2 = 0

    if (max_area > 170000):
        s3 = s3 + 1
        if (s3 == 8):
            # system('say too close')
예제 #26
0
파일: sandbox.py 프로젝트: ghills/pyatzee
#!/usr/bin/python

from dice import dice
from hand import hand
from scores import scoreengine

h = hand()
h.dice[0].held = True
print [d.value for d in h.dice]
print [d.held for d in h.dice]

se = scoreengine()
print ["%s: %d" % (s.title, s.score(h)) for s in se.get_possible(h)]

h.roll()
print [d.value for d in h.dice]

h.unhold_all()
print [d.value for d in h.dice]