Skip to content

Commit

Permalink
refactor: Remove optional colors, as it is a useless construct
Browse files Browse the repository at this point in the history
  • Loading branch information
strakam committed Jan 7, 2025
1 parent 849a281 commit 7c87c34
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions generals/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ class Agent(ABC):
Base class for all agents.
"""

def __init__(self, id: str = "NPC", color: tuple[int, int, int] = (67, 70, 86)):
def __init__(self, id: str = "NPC"):
self.id = id
self.color = color

@abstractmethod
def act(self, observation: Observation) -> Action:
Expand Down
4 changes: 2 additions & 2 deletions generals/agents/expander_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class ExpanderAgent(Agent):
def __init__(self, id: str = "Expander", color: tuple[int, int, int] = (0, 130, 255)):
super().__init__(id, color)
def __init__(self, id: str = "Expander"):
super().__init__(id)

def act(self, observation: Observation) -> Action:
"""
Expand Down
3 changes: 1 addition & 2 deletions generals/agents/random_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ class RandomAgent(Agent):
def __init__(
self,
id: str = "Random",
color: tuple[int, int, int] = (242, 61, 106),
split_prob: float = 0.25,
idle_prob: float = 0.05,
):
super().__init__(id, color)
super().__init__(id)

self.idle_probability = idle_prob
self.split_probability = split_prob
Expand Down
6 changes: 2 additions & 4 deletions generals/envs/gymnasium_generals.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def __init__(
self.npc = npc
self.agent_id = "Agent" if agent is None else agent.id
self.agent_ids = [self.agent_id, self.npc.id]
self.agent_data = {
self.agent_id: {"color": (67, 70, 86) if agent is None else agent.color},
self.npc.id: {"color": self.npc.color},
}
self.colors = [(255, 107, 108), (0, 130, 255)]
self.agent_data = {id: {"color": color} for id, color in zip(self.agent_ids, self.colors)}
assert self.agent_id != npc.id, "Agent ids must be unique - you can pass custom ids to agent constructors."

# Game
Expand Down

0 comments on commit 7c87c34

Please sign in to comment.