Esempio n. 1
0
def playGame(timestamp, playerNames):
    players = dict()
    numPlayers = len(playerNames)
    for name in playerNames:
        f = open(os.path.join(basedir, 'pdb', 'pdb.' + name))
        player = None
        for line in f:
            if line.split()[1] == timestamp:
                player = IRCPlayer(line)
                break
        assert player
        players[player.pos] = player
    print players

    game = PokerGameServer("poker.%s.xml", ['/etc/poker-engine'])
    game.verbose = 1
    game.setVariant("holdem")
    game.setBettingStructure("10-20-pot-limit")

    # Each player sits at the table and buys in 1500.
    # The blinds are posted automatically, no action is required from
    # the player.
    for serial in range(1, 1 + numPlayers):
        #serial = numPlayers - i
        game.addPlayer(serial)
        game.payBuyIn(serial, 1500 * 100)
        game.sit(serial)
        #game.autoBlindAnte(serial)

    game.setDealer(numPlayers - 1)

    game.beginTurn(1)
    print 'current round:', game.current_round
    print 'dealer:', game.player_list[game.dealer]

    print 'next player:', game.getSerialInPosition()
    while game.state in ['blindAnte', 'pre-flop', 'flop', 'turn', 'river']:
        serial = game.getSerialInPosition()
        player = players[serial]
        print serial, game.canAct(serial)

        state = game.state
        if state == 'blindAnte': state = 'pre-flop'
        takeAction(game, state, serial, player)

    print "*" * 70
    for winner in game.winners:
        print "The winner is PLAYER%d with %s" % (
            winner, game.readablePlayerBestHands(winner))

    return game
Esempio n. 2
0
def playGame(timestamp, playerNames):
	players = dict()
	numPlayers = len(playerNames)
	for name in playerNames:
		f = open(os.path.join(basedir, 'pdb', 'pdb.'+name))
		player = None
		for line in f:
			if line.split()[1] == timestamp:
				player = IRCPlayer(line)
				break
		assert player
		players[player.pos] = player
	print players

	game = PokerGameServer("poker.%s.xml", ['/etc/poker-engine'])
	game.verbose = 1
	game.setVariant("holdem")
	game.setBettingStructure("10-20-pot-limit")

	# Each player sits at the table and buys in 1500.
	# The blinds are posted automatically, no action is required from
	# the player.
	for serial in range(1, 1+numPlayers):
		#serial = numPlayers - i
		game.addPlayer(serial)
		game.payBuyIn(serial, 1500*100)
		game.sit(serial)
		#game.autoBlindAnte(serial)

	game.setDealer(numPlayers-1)

	game.beginTurn(1)
	print 'current round:', game.current_round
	print 'dealer:', game.player_list[game.dealer]

	print 'next player:', game.getSerialInPosition()
	while game.state in ['blindAnte', 'pre-flop', 'flop', 'turn', 'river']:
		serial = game.getSerialInPosition()
		player = players[serial]
		print serial, game.canAct(serial)

		state = game.state
		if state == 'blindAnte': state = 'pre-flop'
		takeAction(game, state, serial, player)

	print "*" * 70
	for winner in game.winners:
		print "The winner is PLAYER%d with %s" % ( winner, game.readablePlayerBestHands(winner) )

        return game
Esempio n. 3
0
def setupGame(argv):
    """Process command line arguments and setup game"""
    def usage():
        print >> stderr, "Usage: %s [-a] [-n PLAYERS] [-s]" % argv[0]

    global autoPlay, players, game, mySerial, self_voicing
    try:
        opts, args = getopt(argv[1:], "an:s", ["help"])
    except GetoptError:
        usage()
        exit(2)
    for opt, arg in opts:
        if opt == "-a":
            autoPlay = True
        elif opt == "--help":
            usage()
            exit()
        elif opt == "-n":
            try:
                players = int(arg)
            except:
                print >> stderr, "%s is not a valid argument for %s" % (arg,
                                                                        opt)
                usage()
                exit(3)
        elif opt == "-s":
            self_voicing = True
    game = PokerGameServer("poker.%s.xml", ['/etc/poker-engine'])
    game.verbose = 0
    game.setVariant("holdem")
    game.setBettingStructure("10-15-pot-limit")
    serials = [n + 1 for n in range(players)]
    if not autoPlay:
        mySerial = choice(serials)
    game.registerCallback(pokerEvent)
    for serial in serials:
        game.addPlayer(serial)
        game.payBuyIn(serial, 1500 * 100)
        game.sit(serial)
        if serial == mySerial and not autoPlay:
            game.autoBlindAnte(serial)
        else:
            game.botPlayer(serial)
Esempio n. 4
0
#
# The serial numbers of the four players
#
PLAYER1 = 1
PLAYER2 = 2
PLAYER3 = 3
PLAYER4 = 4

#
# Each player sits at the table and buys in 2000.
# The blinds are posted automatically, no action is required from
# the player.
#
for serial in xrange(PLAYER1, PLAYER4 + 1):
    game.addPlayer(serial)
    game.payBuyIn(serial, 2000*100)
    game.sit(serial)
    game.autoBlindAnte(serial)

#
# Post the blinds and deal the pocket cards. PLAYER1
# is the dealer, PLAYER2 pays the small blind, PLAYER3
# pays the big blind.
#
game.beginTurn(1)
#
# PLAYER4 calls under the gun
#
game.call(PLAYER4)
#
# The dealer and small blind fold
Esempio n. 5
0
#
# The serial numbers of the four players
#
PLAYER1 = 1
PLAYER2 = 2
PLAYER3 = 3
PLAYER4 = 4

#
# Each player sits at the table and buys in 1500.
# The blinds are posted automatically, no action is required from
# the player.
#
for serial in xrange(PLAYER1, PLAYER4 + 1):
    game.addPlayer(serial)
    game.payBuyIn(serial, 1500 * 100)
    game.sit(serial)
    game.autoBlindAnte(serial)

#
# Post the blinds and deal the pocket cards. PLAYER1
# is the dealer, PLAYER2 pays the small blind, PLAYER3
# pays the big blind.
#
game.beginTurn(1)
#game.botPlayer(PLAYER1)
game.botPlayer(PLAYER2)
game.botPlayer(PLAYER3)
game.botPlayer(PLAYER4)

import random
Esempio n. 6
0
#
# The serial numbers of the four players
#
PLAYER1 = 1
PLAYER2 = 2
PLAYER3 = 3
PLAYER4 = 4

#
# Each player sits at the table and buys in 1500.
# The blinds are posted automatically, no action is required from
# the player.
#
for serial in xrange(PLAYER1, PLAYER4 + 1):
    game.addPlayer(serial)
    game.payBuyIn(serial, 1500*100)
    game.sit(serial)
    game.autoBlindAnte(serial)

#
# Post the blinds and deal the pocket cards. PLAYER1
# is the dealer, PLAYER2 pays the small blind, PLAYER3
# pays the big blind.
#
game.beginTurn(1)
#
# PLAYER4 calls under the gun
#
game.call(PLAYER4)
#
# The dealer and small blind fold