oxwhirl / smac

SMAC: The StarCraft Multi-Agent Challenge
MIT License
1.08k stars 228 forks source link

Create method to return a visibility matrix #31

Closed douglasrizzo closed 4 years ago

douglasrizzo commented 4 years ago

The matrix dimensions are n_agents X (n_agents * n_enemies). arr[i, j] is True if agent i sees unit j, False otherwise. In the longest dimension, agents come first, then enemies. I make use of the fact that all units have the same sight range and take O(n_agents / 2 + n_agents * n_enemies) operations to fill the matrix, since the agent/agent part is symmetrical.

I have added a call to the new method in the example agent in order to test it but, on second thought, I don't know if that was appropriate.

samvelyan commented 4 years ago

@douglasrizzo thanks for the contribution!

GoingMyWay commented 4 years ago

@douglasrizzo Dear Douglas How can I use it?

douglasrizzo commented 4 years ago

The method returns a matrix of dimensions n_agents x n_units. If agent n sees unit m, position (n, m) in the matrix will be 1. Otherwise, 0.

GoingMyWay commented 4 years ago

The method returns a matrix of dimensions n_agents x n_units. If agent n sees unit m, position (n, m) in the matrix will be 1. Otherwise, 0.

Thank you. Very helpful enhancement.