Пример #1
0
 def add_line(self, start_point, end_point, timeout=DEFAULT_DEBUG_TIMEOUT):
     data = {
         'start': start_point,
         'end': end_point,
         'color': MAGENTA.repr(),
         'timeout': timeout
     }
     command = DebugCommand(3001, data)
     self.debug_state.append(command)
Пример #2
0
 def add_rectangle(self, top_left, bottom_right):
     data = {
         'top_left': top_left,
         'bottom_right': bottom_right,
         'color': YELLOW.repr(),
         'is_fill': True
     }
     command = DebugCommand(3006, data)
     self.debug_state.append(command)
Пример #3
0
 def send_books(self, cmd_tactics_dict):
     """
     of the form:
     cmd_tactics = {'strategy': strategybook.get_strategies_name_list(),
                    'tactic': tacticbook.get_tactics_name_list(),
                    'action': ['None']}
     """
     cmd = DebugCommand(1001, cmd_tactics_dict)
     self.debug_state.append(cmd)
Пример #4
0
 def send_play_info(self, referee_info, referee_team_info, auto_play_info,
                    auto_flag):
     cmd = DebugCommand(
         1005, {
             'referee': referee_info,
             'referee_team': referee_team_info,
             'auto_play': auto_play_info,
             'auto_flag': auto_flag
         })
     self.debug_state.append(cmd)
Пример #5
0
 def add_circle(self, center, radius):
     data = {
         'center': center,
         'radius': radius,
         'color': CYAN.repr(),
         'is_fill': True,
         'timeout': 0
     }
     circle = DebugCommand(3003, data)
     self.debug_state.append(circle)
Пример #6
0
    def add_influence_map(self, influence_map):

        data = {
            'field_data': influence_map,
            'coldest_numb': -100,
            'hottest_numb': 100,
            'coldest_color': (0, 255, 0),
            'hottest_color': (255, 0, 0),
            'timeout': 2
        }
        command = DebugCommand(3007, data)
        self.debug_state.append(command)
Пример #7
0
 def add_text(self, position, text, color=DEFAULT_TEXT_COLOR):
     data = {
         'position': position,
         'text': text,
         'size': DEFAULT_TEXT_SIZE,
         'font': DEFAULT_TEXT_FONT,
         'align': DEFAULT_TEXT_ALIGN,
         'color': color,
         'has_bold': False,
         'has_italic': False,
         'timeout': DEFAULT_DEBUG_TIMEOUT
     }
     text = DebugCommand(3008, data)
     self.debug_state.append(text)
Пример #8
0
 def add_point(self,
               point,
               color=VIOLET,
               width=5,
               link=None,
               timeout=DEFAULT_DEBUG_TIMEOUT):
     int_point = int(point[0]), int(point[1])
     data = {
         'point': int_point,
         'color': color.repr(),
         'width': width,
         'timeout': timeout
     }
     point = DebugCommand(3004, data, p_link=link)
     self.debug_state.append(point)
Пример #9
0
 def add_circle(self,
                center,
                radius,
                color=CYAN.repr(),
                is_fill=True,
                timeout=DEFAULT_DEBUG_TIMEOUT):
     data = {
         'center': (int(center[0]), int(center[1])),
         'radius': radius,
         'color': color,
         'is_fill': is_fill,
         'timeout': timeout
     }
     circle = DebugCommand(3003, data)
     self.debug_state.append(circle)
Пример #10
0
    def add_vector(self,
                   vector: Position(),
                   start_point=Position(),
                   timeout=DEFAULT_DEBUG_TIMEOUT):

        end_point = start_point + vector
        start_point = (start_point.x, start_point.y)
        end_point = (end_point.x, end_point.y)
        data = {
            'start': start_point,
            'end': end_point,
            'color': CYAN.repr(),
            'timeout': timeout
        }
        command = DebugCommand(3001, data)
        self.debug_state.append(command)
Пример #11
0
 def send_robot_status(self,
                       player_id,
                       tactic,
                       action,
                       target="not implemented"):
     data = {
         'blue': {
             player_id: {
                 'tactic': tactic,
                 'action': action,
                 'target': target
             }
         }
     }
     cmd = DebugCommand(1002, data)
     self.debug_state.append(cmd)
Пример #12
0
 def send_robot_state(self, player_id, battery_volt, time_last_response):
     MAX_BAT = 16.4
     MIN_BAT = 12.0
     battery_lvl = (battery_volt - MIN_BAT) / (MAX_BAT - MIN_BAT) * 100
     time_since_last_response = time.time() - time_last_response
     if time_since_last_response > 5.0:
         battery_lvl = 0
     data = {
         'blue': {
             player_id: {
                 'battery_lvl': battery_lvl,
                 'time_since_last_response': time_since_last_response
             }
         }
     }
     cmd = DebugCommand(1006, data)
     self.debug_state.append(cmd)
Пример #13
0
 def send_robot_strategic_state(self,
                                player: OurPlayer,
                                tactic: str,
                                action: str,
                                target: str = "not implemented"):
     teamcolor_str = player.team.team_color.__str__()
     data = {
         teamcolor_str: {
             player.id: {
                 'tactic': tactic,
                 'action': action,
                 'target': target
             }
         }
     }
     cmd = DebugCommand(1002, data)
     self.debug_state.append(cmd)
Пример #14
0
    def add_multiple_points(self,
                            points,
                            color=VIOLET,
                            width=5,
                            link=None,
                            timeout=DEFAULT_DEBUG_TIMEOUT):
        points_as_tuple = []
        for point in points:
            points_as_tuple.append((int(point[0]), int(point[1])))

        data = {
            'points': points_as_tuple,
            'color': color.repr(),
            'width': width,
            'timeout': timeout
        }
        point = DebugCommand(3005, data, p_link=link)
        self.debug_state.append(point)
Пример #15
0
def wrap_command(raw_command):
    command = DebugCommand(raw_command['type'], raw_command['link'], raw_command['data'])
    command.name = 'ui'
    return command
Пример #16
0
 def add_log(self, level, message):
     log = DebugCommand(2, {'level': level, 'message': message})
     self.debug_state.append(log)
Пример #17
0
 def send_team_color(self):
     cmd = DebugCommand(
         1004,
         {'team_color': TeamColorService().OUR_TEAM_COLOR.name.lower()})
     self.debug_state.append(cmd)
Пример #18
0
def wrap_command(raw_command):
    command = DebugCommand(raw_command['type'], raw_command['link'],
                           raw_command['data'])
    command.name = 'ui'
    return command