コード例 #1
0
def start(phenny, input):
    global game, in_play, starting, arguments, help, temp_cmds
    if not starting:
        starting = True
        args = check_args(phenny, input.group(0))
        if not args:
            starting = False
            return

        if in_play:
            phenny.say(
                "A game is already in play! Wait for it to end, then try again."
            )
        else:
            #NEW BLACKJACK GAME
            if args[0] == "blackjack":
                in_play = True
                join_casino(input)
                game = blackjack.Game(phenny, input.uid, input.nick)
                for item, string in blackjack.help.items():
                    help[item] = string
                for item, args in blackjack.arguments.items():
                    arguments[item] = args
                    temp_cmds.append(item)
            elif args[0] == "poker" or args[0] == "5poker" or args[
                    0] == "7poker" or args[0] == "poker5" or args[
                        0] == "poker7":
                if len(args) < 2:
                    stakes = "mid"
                else:
                    stakes = args[1]

                if args[0] == "7poker" or args[0] == "poker7":
                    cards = 7
                else:
                    cards = 5

                in_play = True
                join_casino(input)
                game = poker.Game(phenny, input.uid, input.nick, cards, stakes)
                for item, string in poker.help.items():
                    help[item] = string
                for item, args in poker.arguments.items():
                    arguments[item] = args
                    temp_cmds.append(item)
        starting = False
コード例 #2
0
ファイル: musebot.py プロジェクト: PiggyBottle/muse-bot
 def main_menu(self, word, word_eol, userdata):
     if '@test ' == word[1][0:6]:
         hexchat.prnt('Success')
         return hexchat.EAT_ALL
     elif word[1].startswith('$anime '):
         if len(word[1]) == 7:
             return hexchat.EAT_ALL
         self.function = AnimeTiming(word[1][7:])
         self.function = None
         return hexchat.EAT_ALL
     elif word[1].startswith('$poll '):
         self.state = 'poll'
         self.function = Poll(word[1][6:])
         self.t = threading.Timer(15, self.poll_complete)
         self.t.start()
         return hexchat.EAT_ALL
     elif word[1][0:13] == '$settimezone ' or word[1].startswith('$time'):
         self.function = TimeZoneCheck(word[1], word[0].lower())
         self.function = None
         return hexchat.EAT_ALL
     elif word[1].startswith('$money'):
         self.function = Money()
         hexchat.command('say %s has %d NanoDollars.' %
                         (word[0], self.function.check(word[0].lower())))
         self.function = None
         return hexchat.EAT_ALL
     elif word[1].startswith('$blackjack'):
         self.state = 'preblackjack'
         hexchat.command('me puts on a tuxedo and sets up the table.')
         hexchat.command(
             'say %s has started a game of blackjack! Everyone is free to $join in! (Once ready, press $start)'
             % (word[0]))
         self.function = blackjack.Game()
         self.add_blackjack_player(word[0].lower())
     else:
         self.setactiveuser(word[0])
         return hexchat.EAT_ALL
コード例 #3
0
ファイル: test.py プロジェクト: SpenserPorter/python_practice
import blackjack
# card1 = blackjack.Card('5','h')
# card2 = blackjack.Card('A','d')
# hand1 = blackjack.Hand([card1, card2])

# print(hand1, hand1.get_value(), hand1.get_cards(0))

number_of_players = input("How many Players?: ")
while True:
    try:
        players = int(number_of_players)
        game1 = blackjack.Game(players)
        break
    except ValueError:
        number_of_players = input("How many Players?: ")

game1.start()

コード例 #4
0
ファイル: main.py プロジェクト: BenMob/BlackJack
# By Benjamin Ombeni
# 01/05/2019

# This is a simplified version on the Casino BlackJack game using OOP in Python.
import blackjack

game = blackjack.Game()
game.start_game()
コード例 #5
0
if __name__ == "__main__":

    st = bj.Strategy()
    mp = bj.MoneyPot(starting_amount=1000, min_bet=10)
    cd = bj.Cards(N_decks=5)

    # hand0 = bj.Hand(cards=cd, strategy=st, money_pot=mp, bet_placed=10)
    # hand0()

    N_games = 10000
    games = np.arange(N_games)
    lengths = np.zeros(N_games)
    plt.figure()
    for k in range(N_games):
        game = bj.Game(N_decks=5,
                       initial_money=1000,
                       min_bet=10,
                       pay_ratio=3. / 2.)
        result, won, lost, pushed = game()
        lengths[k] = len(result)
        plt.plot(result, label="Game %d" % (k + 1))

    plt.xlabel("Number of Hands played")
    plt.ylabel("Money Pot")
    if N_games <= 10:
        plt.legend()

    plt.figure()
    plt.scatter(games, lengths)
    plt.xlabel('Game #')
    plt.ylabel('Hands played')