diff --git a/src/arc_proj/graph.py b/src/arc_proj/graph.py index 4adfe4f..32e08e7 100644 --- a/src/arc_proj/graph.py +++ b/src/arc_proj/graph.py @@ -11,6 +11,7 @@ import networkx as nx import numpy from arc_proj.agent import Agent +import arc_proj.util as util # Node position type NodePos = Tuple[int, int] @@ -269,7 +270,7 @@ class Graph: img = [[(0, 0, 0) for _ in range(self.size[0])] for _ in range(self.size[1])] for node_pos in self.graph.nodes: agent = self.agents.get(node_pos, None) - img[node_pos[1]][node_pos[0]] = agent.color() if agent is not None else [0.5, 0.5, 0.5] + img[node_pos[1]][node_pos[0]] = agent.color() if agent is not None else (0.5, 0.5, 0.5) return img @@ -281,7 +282,15 @@ class Graph: for node_pos in self.graph.nodes: satisfaction = self.agent_satisfaction(node_pos) satisfied = self.agent_satisfied(node_pos) - img[node_pos[1]][node_pos[0]] = [satisfaction, 0.0, satisfied] if satisfaction is not None else [1.0, 0.0, 1.0] + agent = util.try_index_dict(self.agents, node_pos) + threshold = agent.threshold() if agent is not None else None + + match satisfied: + case None : color = (0.5, 0.5, 0.5) + case True : color = (0.0, (satisfaction - threshold) / (1 - threshold), 0.0) + case False: color = (1.0 - satisfaction / threshold, 0.0, 0.0) + + img[node_pos[1]][node_pos[0]] = color return img diff --git a/src/main.py b/src/main.py index e6ea568..8aeb49d 100644 --- a/src/main.py +++ b/src/main.py @@ -227,15 +227,16 @@ def main(): exec_method = ExecMethod.NORMAL if exec_method == ExecMethod.NORMAL: + agent_count = 5 params = RunParams( graph_size=[80, 80], seed=773, - empty_chance=0.1, - agent_weights={ NAgent(NAgentKind.RED): 1, NAgent(NAgentKind.BLUE): 1 }, + empty_chance=0, + agent_weights={ GAgent( agent_idx / (agent_count - 1.0) ): 1.0 for agent_idx in range(agent_count) }, output_json_path=None, - output_img_agent_path=None, - output_img_satisfaction_path=None, - display_method=DisplayMethod.GRAPH, + output_img_agent_path="output", + output_img_satisfaction_path="output", + display_method=DisplayMethod.GRID, rounds_per_display=1 )