def main(): global parameters parameters = parse_args() sys.stdout.write("Creating server with {0} players, ".format( parameters.teams)) print "and {0} as the map\n".format(parameters.map) print "Running server on port {0}\n".format(parameters.port) print "Writing log to {0}".format(parameters.log) map_cache_str = "map.cache" with open(parameters.log, 'w'): pass fileLog = FileLogger(parameters.log) if os.path.isfile(map_cache_str) and parameters.cached_map: with open(map_cache_str, 'r') as f: rooms = pickle.load(f) my_game = game.Game(parameters.map, rooms) with open(map_cache_str, 'r') as f: rooms = pickle.load(f) else: my_game = game.Game(parameters.map) rooms_str = pickle.dumps(my_game.rooms) with open(map_cache_str, 'w') as f: f.write(rooms_str) rooms = pickle.loads(rooms_str) if parameters.show: fileLog.vis = vis.visualizer.Visualizer(rooms, parameters.mapOverlay, debug=parameters.debug_view) serv = MMServer(parameters.teams, my_game, logger=fileLog) serv.run(parameters.port, launch_clients)
def main(): global parameters parameters = parse_args() sys.stdout.write("Creating server with {0} players, ".format( parameters.teams)) print "and {0} as the map\n".format(parameters.map) print "Running server on port {0}\n".format(parameters.port) print "Writing log to {0}".format(parameters.log) map_cache_str = "map.cache" with open(parameters.log, 'w'): pass fileLog = FileLogger(parameters.log) if os.path.isfile(map_cache_str) and parameters.cached_map: with open(map_cache_str, 'r') as f: rooms = pickle.load(f) my_game = game.Game(parameters.map, parameters.turnsinhour, rooms) with open(map_cache_str, 'r') as f: rooms = pickle.load(f) else: my_game = game.Game(parameters.map, parameters.turnsinhour) rooms_str = pickle.dumps(my_game.rooms) with open(map_cache_str, 'w') as f: f.write(rooms_str) rooms = pickle.loads(rooms_str) if parameters.show: fileLog.vis = vis.visualizer.Visualizer(rooms, parameters.mapOverlay, debug=parameters.debug_view) if parameters.scoreboard: fileLog.score = Scoreboard(parameters.scoreboard_url) serv = MMServer(parameters.teams, my_game, logger=fileLog) serv.run(parameters.port, launch_clients) if parameters.scoreboard: fileLog.score.stop()
def test_game(team,team_dir, port): client_list = list() global parameters parameters = parse_args() map_cache_str = "map.cache" fileLog = FileLogger(team+parameters.log) with open(team+parameters.log, 'w'): pass with open(map_cache_str, 'r') as f: rooms = pickle.load(f) my_game = game.Game(parameters.map, 2, rooms) serv = MMServer(parameters.teams, my_game, logger=fileLog) serv.run(port, partial(launch_client_test_game, team_dir, port), time_out=60) return True
def main(): global parameters parameters = parse_args() if parameters.only_log: print "Running Visualizer only" fileLog = FileLogger(None) fileLog.vis = VisualizerThread(parameters.map, parameters.debug_view, parameters.scoreboard) fileLog.vis.start() try: logJsonObject = [] with open(parameters.log) as json_file: for line in json_file: fileLog.print_stuff(line) if(logJsonObject is None): raise Exception except IOError: print("File " + args.logJson + " does not exist") raise exit(1) except Exception: print("Failed to parse log json data") raise exit(1) else: sys.stdout.write("Creating server with {0} players, ".format( parameters.teams)) print "and {0} as the map\n".format(parameters.map) print "Running server on port {0}\n".format(parameters.port) print "Writing log to {0}".format(parameters.log) fileLog = FileLogger(parameters.log) if parameters.show: fileLog.vis = VisualizerThread(parameters.map, parameters.debug_view, parameters.scoreboard) fileLog.vis.start() print "Starting Game" my_game = game.Game(parameters.map, parameters.turnsinhour) serv = MMServer(parameters.teams, my_game, logger=fileLog) serv.run(parameters.port, launch_clients) with open(parameters.log, 'w'): pass fileLog.write_to_file() if parameters.show: fileLog.vis.join() if parameters.scoreboard: fileLog.score.stop()
def main(): global parameters parameters = parse_args() sys.stdout.write("Creating server with {0} players, ".format( parameters.teams)) print "and {0} as the map\n".format(parameters.map) print "Running server on port {0}\n".format(parameters.port) print "Writing log to {0}".format(parameters.log) with open(parameters.log, 'w'): pass fileLog = FileLogger(parameters.log) if parameters.show: fileLog.vis = VisualizerThread(parameters.map, parameters.debug_view, parameters.scoreboard) fileLog.vis.start() print "Starting Game" my_game = game.Game(parameters.map, parameters.turnsinhour) serv = MMServer(parameters.teams, my_game, logger=fileLog) serv.run(parameters.port, launch_clients) if parameters.show: fileLog.vis.join() if parameters.scoreboard: fileLog.score.stop()