Do you already have each agent a
assigned to a single goal g
? If so, I agree with the other answers: A* would work well, although for such a small map it may not matter which pathfinding algorithm you use. If each agent a
can go to any of the goals then you could use Dijkstra's algorithm and stop whenever any goal g
is reached.
If however you want at most one agent a
to be assigned to each goal g
then you need to first assign agents to goals. You could use something like Kuhn-Munkres to make the assignment. Here's the Wikipedia description of the assignment problem:
There are a number of agents and a number of tasks. Any agent can be assigned to perform any task, incurring some cost that may vary depending on the agent-task assignment. It is required to perform all tasks by assigning exactly one agent to each task in such a way that the total cost of the assignment is minimized.
You'll need to come up with costs; you could do that either with the same heuristic you use for A*, or you could calculate the path lengths exactly (perhaps with Dijkstra's or Floyd-Warshall). After you've made the assignment you'll need to find the paths. If you computed the paths in order to get the costs, you'll already have them, but if you used a heuristic, you'll need to use A* at this point to find the paths.