Skip to content
Snippets Groups Projects
Commit 59d0f6fd authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Some flags in random agent for controlling movement and path finding

parent c95ea0f4
No related branches found
No related tags found
1 merge request!89Resolve "simple pathfinding"
Pipeline #48891 failed
......@@ -22,7 +22,9 @@ from cooperative_cuisine.utils import custom_asdict_factory
TIME_TO_STOP_ACTION = 3.0
ADD_RANDOM_MOVEMENTS = True
ADD_RANDOM_MOVEMENTS = False
DIAGONAL_MOVEMENTS = False
AVOID_OTHER_PLAYERS = True
def get_free_neighbours(
......@@ -90,8 +92,9 @@ async def agent():
continue
if movement_graph is None:
movement_graph = create_movement_graph(state, diagonal=True)
movement_graph = create_movement_graph(
state, diagonal=DIAGONAL_MOVEMENTS
)
if counters is None:
counters = defaultdict(list)
......@@ -170,16 +173,17 @@ async def agent():
paths = []
for free in target_free_spaces:
try:
modified_graph = restrict_movement_graph(
graph=movement_graph.copy(),
player_positions=[
p["pos"]
for p in state["players"]
if p["id"] != args.player_id
],
)
path = networkx.astar_path(
modified_graph,
restrict_movement_graph(
graph=movement_graph.copy(),
player_positions=[
p["pos"]
for p in state["players"]
if p["id"] != args.player_id
],
)
if AVOID_OTHER_PLAYERS
else movement_graph,
source,
free,
heuristic=astar_heuristic,
......@@ -314,7 +318,13 @@ async def agent():
random_counter = random.choice(all_counters)
counter_type = random_counter["type"]
task_args = random_counter["pos"]
print(args.player_hash, args.player_id, task_type, counter_type, task_args)
print(
args.player_hash,
args.player_id,
task_type,
counter_type,
task_args,
)
else:
print(args.player_hash, args.player_id, task_type)
task_args = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment