# Path: oscar/agent/custom_agent.py
# class CustomAgent(BaseAgent):
#     """A base agent to write custom scripted agents."""
# 
#     def __init__(self):
#         super().__init__()
#         self._shared = {}
# 
#     def add_shared(self, name, shared):
#         self._shared[name] = shared


from abc import ABC, abstractmethod
from oscar.agent.custom_agent import CustomAgent

    def __init__(self, subordinates: list):
        """
        :param subordinates: a list of agents. These must be initialized already !
        """
        super().__init__()
        self._subordinates = subordinates
        self._locked_choice = False
        self._playing_subordinate = None

    def step(self, obs, locked_choice=None):
        """
        Does some work and choose a subordinate that will play
        :param obs: observations from the game
        :return: an action chosen by a subordinate
        """

        """if not self._locked_choice:
            self._playing_subordinate = self.choose_subordinate(obs)
        play = self._playing_subordinate.step(obs)
        try:
            self._locked_choice = play["locked_choice"]
        except KeyError:
            self._locked_choice = False
        return play"""

        if locked_choice is None:
            locked_choice = self._locked_choice

        self._playing_subordinate = self.choose_subordinate(obs, locked_choice)

# Path: oscar/agent/custom_agent.py
# class CustomAgent(BaseAgent):
#     """A base agent to write custom scripted agents."""
# 
#     def __init__(self):
#         super().__init__()
#         self._shared = {}
# 
#     def add_shared(self, name, shared):
#         self._shared[name] = shared


# Path: oscar/agent/commander/base_commander.py
from abc import ABC, abstractmethod
from oscar.agent.custom_agent import CustomAgent


    def __init__(self, subordinates: list):
        """
        :param subordinates: a list of agents. These must be initialized already !
        """
        super().__init__()
        self._subordinates = subordinates
        self._locked_choice = False
        self._playing_subordinate = None

    def step(self, obs, locked_choice=None):
        """
        Does some work and choose a subordinate that will play
        :param obs: observations from the game
        :return: an action chosen by a subordinate
        """

        """if not self._locked_choice:
            self._playing_subordinate = self.choose_subordinate(obs)
        play = self._playing_subordinate.step(obs)
        try:
            self._locked_choice = play["locked_choice"]
        except KeyError:
            self._locked_choice = False
        return play"""

        if locked_choice is None:
            locked_choice = self._locked_choice

        self._playing_subordinate = self.choose_subordinate(obs, locked_choice)

        play = self._playing_subordinate.step(obs, locked_choice)