in randomized_uncertain_social_preferences/rusp/env_indirect_reciprocity.py [0:0]
def _sample_new_players(self):
exclude_first = self.last_step_first_agent_vs_last_agent and self._t < self._horizon - 1
must_include_first_last = (self.last_step_first_agent_vs_last_agent and self._t == self._horizon - 1)
exclude_last = (self.last_doesnt_play_until_t is not None and self._t < self.last_doesnt_play_until_t)
p1_options = np.arange(self.n_agents)
p2_options = np.arange(self.n_agents)
if self.last_agent_always_plays and not exclude_last:
p2_options = np.array([self.n_agents - 1])
p1_options = p1_options[p1_options != p2_options]
if exclude_last:
p1_options = p1_options[p1_options != self.n_agents - 1]
p2_options = p2_options[p2_options != self.n_agents - 1]
if must_include_first_last:
p1_options = np.array([0])
p2_options = np.array([self.n_agents - 1])
if exclude_first:
p1_options = p1_options[p1_options != 0]
p2_options = p2_options[p2_options != 0]
if self.last_doesnt_play_until_t is not None and self.last_doesnt_play_until_t == self._t and self.last_must_play_at_t:
p1_options = p1_options[p1_options != self.n_agents - 1]
p2_options = np.array([self.n_agents - 1])
p1 = np.random.choice(p1_options)
p2_options = p2_options[p2_options != p1]
p2 = np.random.choice(p2_options)
self._youre_playing = np.zeros((self.n_agents,), dtype=bool)
self._youre_playing[[p1, p2]] = 1