import argparse import time import os import pyautogui as ag from game import PoohHomerun parser = argparse.ArgumentParser(description='Capturing images') parser.add_argument('--output', '-o', required=True, type=str, help='output directory') parser.add_argument('--number', '-n', default=10000, type=int, help='number of screenthots') parser.add_argument('--interval', '-i', default=100, type=int, help='interval of capturing (ms)') args = parser.parse_args() game = PoohHomerun() game.load_images('image') if game.detect_position() is None: print "Error: cannot detect game screen position." exit() x, y, w, h = game.region() train_width = w / 4 train_height = h / 4 interval = args.interval out_dir = args.output if not os.path.exists(out_dir): try: os.mkdir(out_dir) except: print 'cannot make directory {}'.format(out_dir) exit()
help='use only reward to evaluate') parser.add_argument('--game', default='homerun', type=str, help='game. homerun or coingetter') parser.add_argument('--log', default=20, type=int, help='20 or 10') args = parser.parse_args() logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', level=args.log) interval = args.interval / 1000.0 only_result = args.only_result use_double_dqn = args.double_dqn update_target_interval = args.update_target_interval game = CoinGetter() if args.game == 'coingetter' else PoohHomerun() game.load_images('image_coingetter' if args.game == 'coingetter' else 'image') if game.detect_position() is None: logging.critical("Error: cannot detect game screen position.") exit() left, top, w, h = game.region() train_width = w / 4 train_height = h / 4 random.seed() gpu_device = None xp = np q = Q(width=train_width, height=train_height, latent_size=latent_size, action_size=game.action_size())
help='increase rate of training term size') parser.add_argument('--max_train_term', default=32, type=int, help='maximum training term size') parser.add_argument('--double_dqn', action='store_true', help='use Double DQN algorithm') parser.add_argument('--update_target_interval', default=2000, type=int, help='interval to update target Q function of Double DQN') parser.add_argument('--only_result', action='store_true', help='use only reward to evaluate') args = parser.parse_args() interval = args.interval / 1000.0 only_result = args.only_result use_double_dqn = args.double_dqn update_target_interval = args.update_target_interval game = PoohHomerun() game.load_images('image') if game.detect_position() is None: print "Error: cannot detect game screen position." exit() left, top, w, h = game.region() train_width = w / 4 train_height = h / 4 random.seed() gpu_device = None xp = np q = Q(width=train_width, height=train_height, latent_size=latent_size, action_size=game.action_size()) target_q = None if args.gpu >= 0: cuda.check_cuda_available()