def main(): logging.basicConfig(level = logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s') proxy = ServerProxy("http://localhost:8080") logging.info("Logging in with team %s and password %s" % (team, password)) session = proxy.login(team, password) logging.info("Initiated session %s" % (session)) #session = "lgpb1yqve5tn0ggu3rxoktmt112uthvfbgemnou8" try: res = proxy.get_info(session) turn_num = res['turn_num'] logging.info("Sending add_request()") res = proxy.add_request(session, turn_num, {"5": {ACTION_MOVE: MOVE_DOWN}, "4": {ACTION_SHOOT: (7, 3)}}) logging.info("Response: %s" % (repr(res))) finally: logging.info("Logging out") res = proxy.logout(session) logging.info("Response: %s" % (repr(res))) logging.info("Finished!")
def main(): logging.basicConfig(level = logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s') proxy = ServerProxy("http://localhost:8080") logging.info("Logging in with team %s and password %s" % (team, password)) session = proxy.login(team, password) logging.info("Initiated session %s" % (session)) try: while True: #logging.info("Sending get_info()") res = proxy.get_info(session) #logging.info("Response: %s" % (repr(res))) turn_num = res['turn_num'] simulator = Simulator.from_external_status(res['status']) print "TURN %d" % (turn_num) simulator.print_field() proxy.wait_for_simulation(session) print finally: logging.info("Logging out") res = proxy.logout(session) logging.info("Response: %s" % (repr(res))) logging.info("Finished!")