Пример #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
Пример #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
Пример #3
0
#
# The dealer and small blind fold
#
game.fold(PLAYER1)
game.fold(PLAYER2)
#
# The big blind checks
#
game.check(PLAYER3)
#
# PLAYER3 and PLAYER4 check the flop
#
game.check(PLAYER3)
game.check(PLAYER4)
#
# PLAYER3 and PLAYER4 check the turn
#
game.check(PLAYER3)
game.check(PLAYER4)
#
# PLAYER3 and PLAYER4 check the river
#
game.check(PLAYER3)
game.check(PLAYER4)
#
# Print the winner(s)
#
print "*" * 70
for winner in game.winners:
    print "The winner is PLAYER%d with %s" % ( winner, game.readablePlayerBestHands(winner) )
Пример #4
0
#
game.fold(PLAYER1)
game.fold(PLAYER2)
#
# The big blind checks
#
game.check(PLAYER3)
#
# PLAYER3 and PLAYER4 check the flop
#
game.check(PLAYER3)
game.check(PLAYER4)
#
# PLAYER3 and PLAYER4 check the turn
#
game.check(PLAYER3)
game.check(PLAYER4)
#
# PLAYER3 and PLAYER4 check the river
#
game.check(PLAYER3)
game.check(PLAYER4)
'''
#
# Print the winner(s)
#
print "*" * 70
for winner in game.winners:
    print "The winner is PLAYER%d with %s" % (
        winner, game.readablePlayerBestHands(winner))