Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning agents with done components #421

Open
rusu24edward opened this issue Aug 8, 2023 · 2 comments
Open

Assigning agents with done components #421

rusu24edward opened this issue Aug 8, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@rusu24edward
Copy link
Collaborator

We have some correspondence between components and agents: MoveActors work with MovingAgent, Attackors work with AttackingAgent, HealthState works with HealthAgent, Observers work with ObservingAgents (more generally). We ought to consider some kinds of correspondence between done conditions and the agent type.

Alternatively, we can assign a mapping between the done condition and the agents to which it applies.

@rusu24edward rusu24edward added the enhancement New feature or request label Aug 8, 2023
@rusu24edward rusu24edward added this to the Coming... eventually milestone Aug 8, 2023
@rusu24edward
Copy link
Collaborator Author

For example, suppose there are two teams, each with a target. The game will end when one of the teams takes out its target. The TargetDestroyedDone calculates the done condition for all agents. So we have to split it in the following way:

def get_all_done(self, **kwargs):
    attackers_done = all([
        self.target_done.get_done(agent)
        for agent in self.agents.values()
        if agent.id.startswith('A') and isinstance(agent, Agent)
    ])
    defenders_done = all([
        self.target_done.get_done(agent)
        for agent in self.agents.values()
        if agent.id.startswith('D') and isinstance(agent, Agent)
    ])
    return attackers_done or defenders_done

@rusu24edward
Copy link
Collaborator Author

We have also duplicated the above code with checking isinstance(DefensiveTeam) instead of id.startswith('D'). It's a bit cleaner, but still not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant