Example #1
0
    def init_game(self,init_stack=500,blinds=(1,2,0)):
        self.g = poker.Game(self.nplayers, init_stack=init_stack, blinds=blinds)

        [x.ask_name() for x in self.threads]
        while not all([x.ready for x in self.threads]):
            pass

        [x.send_message('Everyone ready.\n') for x in self.threads]
        for i in xrange(self.nthreads):
            self.g.players[i].name = self.threads[i].name
Example #2
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
Example #3
0
from tools import Series
from tools import Clock
import poker as pkr

game = pkr.Game()
game.add_player()
game.add_player()
game.add_player()
player_1 = game.players[0]
player_2 = game.players[1]
player_3 = game.players[2]

Clock.elapsed()
results = []
n_stories = 100000
for i in range(n_stories):
    game.reset()
    game.deal_card_to_player(player_1, "As")
    game.deal_card_to_player(player_1, "Ks")

    game.deal_card_to_player(player_2, "9d")
    game.deal_card_to_player(player_2, "9c")

    game.deal_card_to_player(player_3)
    game.deal_card_to_player(player_3)

    game.deal_flop()
    game.deal_turn()
    game.deal_river()

    winning_players = game.get_winning_players()
Example #4
0
from tools import Series, Clock
import poker as pkr

game = pkr.Game(
)  # creates a game with a board and a 52 card deck (but no player)
# adding two players
game.add_player()
game.add_player()
player_1 = game.players[0]
player_2 = game.players[1]

Clock.elapsed()
# Monte Carlo
results = []
n_stories = 100000
for i in range(n_stories):
    game.reset(shuffle_deck=True)
    game.deal_card_to_player(
        player_1, "9s")  # always dealing the same cards to player 1.
    game.deal_card_to_player(player_1, "8s")

    game.deal_card_to_player(player_2)  # player 2 receives cards at random.
    game.deal_card_to_player(player_2)

    game.deal_flop()
    game.deal_turn()
    game.deal_river()

    # print(game)  # <- uncomment these two lines if you want a visualization of what is happening during the simulation
    # print()