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)
# 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 while game.possibleActions(PLAYER1): actions = game.possibleActions(PLAYER1) assert len(actions) rnd = random.randint(0, len(actions) - 1) action = actions[rnd] if action == 'fold': game.fold(PLAYER1) elif action == 'check': game.check(PLAYER1) elif action == 'call': game.call(PLAYER1)
# 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 while game.possibleActions(PLAYER1): actions = game.possibleActions(PLAYER1) assert len(actions) rnd = random.randint(0, len(actions)-1) action = actions[rnd] if action == 'fold': game.fold(PLAYER1) elif action == 'check': game.check(PLAYER1) elif action == 'call': game.call(PLAYER1)