Example #1
0
def run(level = "map22", commanders = ["mycmd.macbethCommander", "mycmd.macbethCommander"]):
    try:
        sys.stderr.write('.')
        runner = platform.ConsoleRunner()
        runner.accelerate()
        app = application.CaptureTheFlag(commanders, level, quiet = True, games = 1)
        runner.run(app)
        sys.stderr.write('o')
        return level, app.scores
    except Exception as e:
        print >> sys.stderr, str(e)
        tb_list = callstack.format(sys.exc_info()[2])
        for s in tb_list:
            print >> sys.stderr, s
        raise
    except KeyboardInterrupt:
        return None 
Example #2
0
def run(args):
    try:
        level, commanders = args
        sys.stderr.write('.')
        runner = platform.ConsoleRunner()
        runner.accelerate()
        app = application.CaptureTheFlag(list(commanders), level, quiet = True, games = 1)
        runner.run(app)
        sys.stderr.write('o')
        return level, app.scores
    except Exception as e:
        print >> sys.stderr, str(e)
        tb_list = callstack.format(sys.exc_info()[2])
        for s in tb_list:
            print >> sys.stderr, s
        raise
    except KeyboardInterrupt:
        return None 
Example #3
0
def run(args):
    try:
        level, commanders = args
        sys.stderr.write('.')
        runner = platform.ConsoleRunner()
        runner.accelerate()
        app = application.CaptureTheFlag(list(commanders), level, quiet = True, games = 1)
        t = random.randint(3,10)
        time.sleep(t)
        runner.run(app)
        sys.stderr.write('o')
        return level, app.scores
    except Exception as e:
        print >> sys.stderr, str(e)
        tb_list = callstack.format(sys.exc_info()[2])
        for s in tb_list:
            print >> sys.stderr, s
        raise
    except KeyboardInterrupt:
        return None 
Example #4
0
            from reload import reset
            reset()


# This is the entry point for the whole application.  The main function is
# called only when the module is first executed.  Subsequent resetting or
# refreshing cannot automatically update this __main__ module.
if __name__ == '__main__':
    import sys
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--console', type=bool)
    parser.add_argument('competitors', nargs='*')
    args, _ = parser.parse_known_args()

    try:
        if args.console:
            main(platform.ConsoleRunner, args.competitors)
        else:
            main(platform.WindowRunner, args.competitors)

    except Exception as e:
        print str(e)
        tb_list = callstack.format(sys.exc_info()[2])
        for s in tb_list:
            print s
        raise

Example #5
0
        default=random.choice(levels),
        help=
        'Specify which level should be loaded, e.g. map00 or map21.  These are loaded from the .png and .ini file combination in #/assets/.'
    )
    parser.add_argument(
        'competitors',
        nargs='*',
        help=
        'The name of a script and class (e.g. mybot.Placeholder) implementing the Commander interface.  Files are exact, but classes match by substring.'
    )
    args, _ = parser.parse_known_args()

    try:
        if args.console:
            main(platform.ConsoleRunner,
                 args.competitors,
                 accel=args.accelerate,
                 level=args.level)
        else:
            main(platform.WindowRunner,
                 args.competitors,
                 accel=args.accelerate,
                 level=args.level)

    except Exception as e:
        print >> sys.stderr, str(e)
        tb_list = callstack.format(sys.exc_info()[2])
        for s in tb_list:
            print >> sys.stderr, s
        raise