code: def remove_agent(self, agent: GUIAgent):
          
          self.index_manager.free_index(agent.overall_index)
          self.agents.remove(agent)
          self.update_teams_listwidgets()
          self.overall_config.set_value(MATCH_CONFIGURATION_HEADER, PARTICIPANT_COUNT_KEY, len(self.agents))
          self.overall_config.set_value(PARTICIPANT_CONFIGURATION_HEADER, PARTICIPANT_LOADOUT_CONFIG_KEY, "None", agent.overall_index)
          if len(self.agents) == 0:
              return
          if agent.get_team() == 0:
              if self.blue_listwidget.count() != 0:
                  self.blue_listwidget.setCurrentRow(self.blue_listwidget.count() - 1)
              else:
                  self.orange_listwidget.setCurrentRow(self.orange_listwidget.count() - 1)
          else:
              if self.orange_listwidget.count() != 0:
                  self.orange_listwidget.setCurrentRow(self.orange_listwidget.count() - 1)
              else:
                  self.blue_listwidget.setCurrentRow(self.blue_listwidget.count() - 1)
docs: Removes the given agent.
          :param agent: the agent to remove
          :return: