social_dilemmas/envs/map_env.py
def find_visible_agents(self, agent_id):
        """Returns all the agents that can be seen by agent with agent_id
        Args
        ----
        agent_id: str
            The id of the agent whose visible agents we are asking about
        Returns
        -------
        visible_agents: list
            which agents can be seen by the agent with id "agent_id"
        """
        agent_pos = self.agents[agent_id].pos
        upper_lim = int(agent_pos[0] + self.agents[agent_id].row_size)
        lower_lim = int(agent_pos[0] - self.agents[agent_id].row_size)
        left_lim = int(agent_pos[1] - self.agents[agent_id].col_size)
        right_lim = int(agent_pos[1] + self.agents[agent_id].col_size)

        # keep this sorted so the visibility matrix is always in order
        other_agent_pos = [
            self.agents[other_agent_id].pos
            for other_agent_id in sorted(self.agents.keys())
            if other_agent_id != agent_id
        ]
        return np.array(
            [
                1
                if (lower_lim <= agent_tup[0] <= upper_lim and left_lim <= agent_tup[1] <= right_lim)
                else 0
                for agent_tup in other_agent_pos
            ],
            dtype=np.uint8,
        )
Returns all the agents that can be seen by agent with agent_id
        Args
        ----
        agent_id: str
            The id of the agent whose visible agents we are asking about
        Returns
        -------
        visible_agents: list
            which agents can be seen by the agent with id "agent_id"
        
Returns all the agents that can be seen by agent with agent_id
Args

str
The id of the agent whose visible agents we are asking about
Returns

list
which agents can be seen by the agent with id "agent_id"
Returns all the agents that can be seen by agent with agent_id Args str The id of the agent whose visible agents we are asking about Returns list which agents can be seen by the agent with id " agent_id "
def find_visible_agents(self, agent_id):
        agent_pos = self.agents[agent_id].pos
        upper_lim = int(agent_pos[0] + self.agents[agent_id].row_size)
        lower_lim = int(agent_pos[0] - self.agents[agent_id].row_size)
        left_lim = int(agent_pos[1] - self.agents[agent_id].col_size)
        right_lim = int(agent_pos[1] + self.agents[agent_id].col_size)
        other_agent_pos = [
            self.agents[other_agent_id].pos
            for other_agent_id in sorted(self.agents.keys())
            if other_agent_id != agent_id
        ]
        return np.array(
            [
                1
                if (lower_lim <= agent_tup[0] <= upper_lim and left_lim <= agent_tup[1] <= right_lim)
                else 0
                for agent_tup in other_agent_pos
            ],
            dtype=np.uint8,
        )
def find_visible_agents ( self , agent_id ) : agent_pos = self . agents [ agent_id ] . pos upper_lim = int ( agent_pos [ 0 ] + self . agents [ agent_id ] . row_size ) lower_lim = int ( agent_pos [ 0 ] - self . agents [ agent_id ] . row_size ) left_lim = int ( agent_pos [ 1 ] - self . agents [ agent_id ] . col_size ) right_lim = int ( agent_pos [ 1 ] + self . agents [ agent_id ] . col_size ) other_agent_pos = [ self . agents [ other_agent_id ] . pos for other_agent_id in sorted ( self . agents . keys ( ) ) if other_agent_id != agent_id ] return np . array ( [ 1 if ( lower_lim <= agent_tup [ 0 ] <= upper_lim and left_lim <= agent_tup [ 1 ] <= right_lim ) else 0 for agent_tup in other_agent_pos ] , dtype = np . uint8 , )
Returns all the agents that can be seen by agent with agent_id
Args
Returns all the agents that can be seen by agent with agent_id Args
"""Returns all the agents that can be seen by agent with agent_id
        Args
        ----
        agent_id: str
            The id of the agent whose visible agents we are asking about
        Returns
        -------
        visible_agents: list
            which agents can be seen by the agent with id "agent_id"
        """ # keep this sorted so the visibility matrix is always in order
self
agent_id