| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from .environment import Environment | |
| def calculate_score(env: Environment) -> dict[str, int]: | |
| scores = {} | |
| for aid, agent in env.agents.items(): | |
| scores[aid] = agent.score | |
| return scores | |
| def rank_agents(env: Environment) -> list[tuple[str, int]]: | |
| scored = [(aid, agent.score) for aid, agent in env.agents.items()] | |
| scored.sort(key=lambda x: x[1], reverse=True) | |
| return scored | |