import cPickle as pickle import sys import itertools import os import time import utility utility.fix_paths() import pokeher.cards as c from pokeher.hand_simulator import HandSimulator from pokeher.utility import MathUtils class PreflopCalculator(object): """Estimates the average value, in % of pots won, for a 2 card hole hand. Currently only useful for heads up texas hold'em """ VERBOSE = False def run(self, tries): """Calculates the win % for each preflop hand, returns the mapping""" cards = c.full_deck() self.wins = {} self.tries = tries for count, two_cards in enumerate(itertools.combinations(cards, 2)): t1 = time.clock() hand = c.Hand(two_cards[0], two_cards[1]) hand_string = hand.simple()
sent_doc_path = output_path + "/sent_doc.json" logging.info("Saving tokenization information...") with open(pos_path, 'w') as file_out: json.dump(pos_sentences, file_out) with open(doc_sent_path, 'w') as file_out: json.dump(document_sentences, file_out) with open(sent_doc_path, 'w') as file_out: json.dump(sentence_documents, file_out) def parse(): """Handle all command line argument parsing. Returns the parsed args object from the parser """ parser = argparse.ArgumentParser() parser = utility.add_common_parsing(parser) cmd_args = parser.parse_args() return cmd_args if __name__ == "__main__": ARGS = parse() utility.init_logging(ARGS.log_path) input_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.input_path, ARGS.output_path) tokenize(input_path, output_path, ARGS.count, ARGS.overwrite)
logging.info("document data saved to '%s'", output_path) def parse(): """Handle all command line argument parsing. Returns the parsed args object from the parser """ parser = argparse.ArgumentParser() parser = utility.add_common_parsing(parser) parser.add_argument( "--bias-file", dest="bias_file", type=str, required=False, default="", metavar="<str>", help="the csv with the leanings", ) cmd_args = parser.parse_args() return cmd_args if __name__ == "__main__": ARGS = parse() utility.init_logging(ARGS.log_path) input_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.input_path, ARGS.output_path) bias_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.bias_file, ARGS.output_path) add_lean(input_path, output_path, bias_path)
"--documents", dest="documents", type=str, required=False, default=None, metavar="<str>", help="The input path for the documents json", ) parser.add_argument( "--aspects", dest="aspects", type=str, required=False, default=None, metavar="<str>", help="The input path for the aspects json", ) cmd_args = parser.parse_args() return cmd_args if __name__ == "__main__": ARGS = parse() utility.init_logging(ARGS.log_path) input_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.input_path, ARGS.output_path) documents_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.documents, ARGS.output_path) aspects_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.aspects, ARGS.output_path) gen_report(input_path, output_path, documents_path, aspects=aspects_path, overwrite=ARGS.overwrite)
#!/usr/bin/python import sys import utility utility.fix_paths() from pokeher.wiring import IOPokerBot from pokeher.theaigame import TheAiGameParserDelegate, TheAiGameActionDelegate class CheckBrain(object): def __init__(self, bot): self.bot = bot self.bot.no_logging = True self.parser = self.bot.set_up_parser({}, self.do_turn) def parse_line(self, line): self.parser.handle_line(line) def do_turn(self, bot, time_left_ms): self.bot.check() class CheckFoldBot(IOPokerBot, TheAiGameParserDelegate, TheAiGameActionDelegate): """Dummy poker bot that only checks""" def add_brain(self): self.brain = CheckBrain(self) if __name__ == '__main__': bot = CheckFoldBot(sys.stdin, sys.stdout, sys.stderr) bot.run()
import sys import utility; utility.fix_paths() from theaigame_arena import TheAiGameArena class GauntletArena(object): """ Repeatedly runs a challenger bot against the opponents listed in the TRIALS object. Reports statistics about performance afterwards. """ TRIALS = { 10: [ "agents/check_fold_bot.py", ], 50: [ "agents/call_bot.py", "agents/raise_bot.py", "agents/call_raise_bot.py", ], # Old versions of this bot 100: [ "../old_bots/v18/pokeher/theaigame_bot.py", "../old_bots/v30/pokeher/theaigame_bot.py", "../old_bots/v37/pokeher/theaigame_bot.py", ], } BOT_LOAD_DELAY_SECS = 0.1 def __init__(self, challenger, percentage=100): self.challenger = challenger
"--documents", dest="documents", type=str, required=False, default="", metavar="<str>", help="the document set", ) parser.add_argument( "--model", dest="model", type=str, required=False, default="", metavar="<str>", help="the model", ) cmd_args = parser.parse_args() return cmd_args if __name__ == "__main__": ARGS = parse() utility.init_logging(ARGS.log_path) input_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.input_path, ARGS.output_path) documents_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.documents, ARGS.output_path) model_path, output_path = utility.fix_paths(ARGS.experiment_path, ARGS.model, ARGS.output_path) examine(input_path, output_path, documents_path, model_path)