Skip to content

Commit

Permalink
Make heuristic agents deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkickling committed Jan 29, 2025
1 parent d620792 commit b3e896d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions malsim/agents/heuristic_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def get_next_action(
selected_node_cost = math.inf
selected_node = None

# To make it deterministic
agent.action_surface.sort(key=lambda n: n.id)

for node in agent.action_surface:
node_cost = node.extras.get('reward', 0)

Expand Down Expand Up @@ -85,6 +88,9 @@ def get_next_action(
selected_node_cost = math.inf
selected_node = None

# To make it deterministic
agent.action_surface.sort(key=lambda n: n.id)

for node in agent.action_surface:
node_cost = node.extras.get('reward', 0)

Expand Down

0 comments on commit b3e896d

Please sign in to comment.