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
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
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)
# poker-engine # import sys, os sys.path.insert(0, "..") from pokerengine.pokergame import PokerGameServer # # Instantiate a poker engine for a hold'em game with a 10/20 pot limit # betting structure. The variant and betting structure descriptions # will be read from the conf/poker.holdem.xml and conf/poker.10-20-pot-limit.xml # files. # game = PokerGameServer("poker.%s.xml", ['conf', '../conf', '/etc/poker-engine']) game.verbose = 1 game.setVariant("holdem") game.setBettingStructure("10-20-pot-limit") # # 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.
# import sys, os sys.path.insert(0, "..") from pokerengine.pokergame import PokerGameServer # # Instantiate a poker engine for a hold'em game with a 10/15 pot limit # betting structure. The variant and betting structure descriptions # will be read from the conf/poker.holdem.xml and conf/poker.10-15-pot-limit.xml # files. # game = PokerGameServer("poker.%s.xml", ['conf', '../conf', '/etc/poker-engine']) game.verbose = 1 game.setVariant("holdem") game.setBettingStructure("10-15-pot-limit") # # 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.