DHC
DHC copied to clipboard
Unreachable agent targets might be generated.
# ... line 175 at file enviorment.py
for i in range(self.num_agents):
pos_idx = random.randint(0, pos_num - 1)
partition_idx = 0
for partition in partition_list:
if pos_idx >= len(partition):
pos_idx -= len(partition)
partition_idx += 1
else:
break
pos = random.choice(partition_list[partition_idx])
partition_list[partition_idx].remove(pos)
self.agents_pos[i] = np.asarray(pos, dtype=np.int)
pos = random.choice(partition_list[partition_idx])
partition_list[partition_idx].remove(pos)
self.goals_pos[i] = np.asarray(pos, dtype=np.int)
partition_list = [partition for partition in partition_list if len(partition) >= 2]
pos_num = sum([len(partition) for partition in partition_list])
This might not be a right way to generate positions for the agents. Because the connectivity of the partition may be disrupted after the addition of the agents. Which may generate unreachable agent targets.