src_code/controllers/basic_controller_influence.py [408:441]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def _build_alone_inputs(self, batch, t):
        # Assumes homogenous agents with flat observations.
        # Other MACs might want to e.g. delegate building inputs to each agent
        bs = batch.batch_size
        inputs_alone = []
        inputs_alone.append(batch["obs_alone"][:, t])  # b1av
        if self.args.obs_last_action:
            if t == 0:
                inputs_alone.append(th.zeros_like(batch["actions_onehot"][:, t]))
            else:
                inputs_alone.append(batch["actions_onehot"][:, t-1])
        if self.args.obs_agent_id:
            inputs_alone.append(th.eye(1, device=batch.device).expand(self.n_agents, -1).unsqueeze(0).expand(bs, -1, -1))

        inputs_alone = th.cat([x.reshape(bs*self.n_agents, -1) for x in inputs_alone], dim=1)
        return inputs_alone

    def _get_input_shape(self, scheme):
        input_shape = scheme["obs"]["vshape"]
        if self.args.obs_last_action:
            input_shape += scheme["actions_onehot"]["vshape"][0]
        if self.args.obs_agent_id:
            input_shape += self.n_agents

        return input_shape

    def _get_input_alone_shape(self, scheme):
        input_alone_shape = scheme["obs_alone"]["vshape"]
        if self.args.obs_last_action:
            input_alone_shape += scheme["actions_onehot"]["vshape"][0]
        if self.args.obs_agent_id:
            input_alone_shape += 1

        return input_alone_shape
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src_code/controllers/basic_controller_interactive.py [346:379]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def _build_alone_inputs(self, batch, t):
        # Assumes homogenous agents with flat observations.
        # Other MACs might want to e.g. delegate building inputs to each agent
        bs = batch.batch_size
        inputs_alone = []
        inputs_alone.append(batch["obs_alone"][:, t])  # b1av
        if self.args.obs_last_action:
            if t == 0:
                inputs_alone.append(th.zeros_like(batch["actions_onehot"][:, t]))
            else:
                inputs_alone.append(batch["actions_onehot"][:, t-1])
        if self.args.obs_agent_id:
            inputs_alone.append(th.eye(1, device=batch.device).expand(self.n_agents, -1).unsqueeze(0).expand(bs, -1, -1))

        inputs_alone = th.cat([x.reshape(bs*self.n_agents, -1) for x in inputs_alone], dim=1)
        return inputs_alone

    def _get_input_shape(self, scheme):
        input_shape = scheme["obs"]["vshape"]
        if self.args.obs_last_action:
            input_shape += scheme["actions_onehot"]["vshape"][0]
        if self.args.obs_agent_id:
            input_shape += self.n_agents

        return input_shape

    def _get_input_alone_shape(self, scheme):
        input_alone_shape = scheme["obs_alone"]["vshape"]
        if self.args.obs_last_action:
            input_alone_shape += scheme["actions_onehot"]["vshape"][0]
        if self.args.obs_agent_id:
            input_alone_shape += 1

        return input_alone_shape
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



