def handle_message_play(self, msg_args): matchid, action, outcome, percepts = msg_args action = Action(self.role, action) outcome = Action(self.role, outcome) percepts = Percepts([Percept(self.role, percept) for percept in percepts]) next_action = self.player_play(action, outcome, percepts, timeout=self.clock_left()) return Message(MessageType.ACTION, [next_action])
def handle_message_stop(self, msg_args): matchid, actions, deterministic_actions = msg_args jointaction = self.simulator.actionlist2jointaction(actions) deterministic_jointaction = self.simulator.actionlist2jointaction(deterministic_actions) goal_value = self.player_stop(jointaction, deterministic_jointaction, timeout=self.clock_left()) self.matchInfo.add_result(self.role, goal_value) return Message(MessageType.DONE)
def handle_message_stop(self, msg_args): matchid, round, action, percepts = msg_args action = Action(self.role, action) percepts = Percepts([Percept(self.role, percept) for percept in percepts]) goal_value = self.player_stop(action, percepts, timeout=self.clock_left()) self.matchInfo.add_result(self.role, goal_value) return Message(MessageType.DONE)
def handle_message_start(self, msg_args): matchid, role, gdl_rules, startclock, playclock = msg_args self.set_reply_deadline(startclock) if self.simulator is None: self.simulator = InferenceInterface(gdl_rules) else: self.simulator.clear_engine() self.matchInfo = MatchInfo(matchid, gdl_rules, startclock, playclock, self.simulator.get_gamesettings()) self.role = role self.player_start(timeout=self.clock_left()) return Message(MessageType.READY)
def do_POST(self): try: rcv_time = time.time() length = int(self.headers['content-length']) msg = self.rfile.read(length).decode('unicode_escape') print(f"<= {repr(msg)}") msg = Message.parse(msg) response = self.server.handle_message(msg, rcv_time) if response is not None: self.respond(str(response)) except Exception as e: logging.error('Error: ' + str(e) + '\n') traceback.print_exc()
def handle_message_play(self, msg_args): matchid, actions, deterministic_actions = msg_args jointaction = self.simulator.actionlist2jointaction(actions) deterministic_jointaction = self.simulator.actionlist2jointaction(deterministic_actions) action = self.player_play(jointaction, deterministic_jointaction, timeout=self.clock_left()) return Message(MessageType.ACTION, [action])