import numpy as np
-
Archived from the IMDb Discussion Forums — The Matrix
ChristKillerman — 7 months ago(August 07, 2025 12:08 PM)
import numpy as np
class AgentSmith:
def init(self):
self.targets = [] # List of targets to eliminate
self.threat_level = 0 # Current threat level
def detect_threat(self, entity):Assess the threat level of an entity
if entity["type"] == "human":
self.threat_level += 1
self.targets.append(entity)
def eliminate_target(self, target):Eliminate a target
if target in self.targets:
self.targets.remove(target)
print(f"Target {target['name']} eliminated")
def update(self):Update Agent Smith's state
if self.targets:
closest_target = min(self.targets, key=lambda x: np.linalg.norm(x["position"] - self.position))
self.chase_target(closest_target)
def chase_target(self, target):Chase a target
print(f"Chasing target {target['name']}")
Update Agent Smith's position to move towards the target
self.position += (target["position"] - self.position) / np.linalg.norm(target["position"] - self.position)
Example usage:
agent_smith = AgentSmith()
agent_smith.position = np.array([0, 0])
human = {"name": "Neo", "type": "human", "position": np.array([10, 10])}
agent_smith.detect_threat(human)
agent_smith.update()
Hrabak means greedy