[Python] How do I prevent two VWAgent workers from deadlocking when they face each other after...

Discussão em 'Python' iniciado por Stack, Novembro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on a multi-agent grid environment using the VWAgent framework. I have three agents:

    • White: explores and broadcasts cleaning assignments
    • Green & Orange: wait until assignments, then move to clean their tiles

    White explores correctly, broadcasts once, and then both workers start moving. The problem begins after the assignments: Green and Orange end up facing each other on the same corridor and both freeze forever. Neither moves, neither backs off — complete deadlock.

    Here is the relevant part of the worker decide() method:

    def decide(self) -> Iterable[VWAction]:
    # Broadcast EXACTLY ONCE to avoid spamming workers
    if self.__sent_assignments and self.__broadcast_action:
    action = self.__broadcast_action
    self.__broadcast_action = None # Clear it so we don't send again
    return [cast(VWAction, action)]

    if self.__backoff > 0:
    return [VWIdleAction()]

    obs = self.get_latest_observation()
    appearance = self.get_own_appearance()

    collision_action = self.__handle_collision(obs)
    if collision_action is not None:
    return [collision_action]

    pos = self.get_own_position()

    if self.__heading_home:
    if (pos.get_x(), pos.get_y()) == self.__home_target:
    self.__heading_home = False
    else:
    return [self.__move_towards(target=self.__home_target)]

    • White finishes mapping and broadcasts tasks (good).
    • Green and Orange start moving (good).
    • They meet in a corridor facing each other.
    • __handle_collision() keeps returning “blocked” for both.
    • Both agents idle forever → deadlock.

    One worker should yield or back off so the other can pass.

    Both freeze because their movement logic is symmetric and neither gives way.

    Question


    How can I modify my movement/collision logic so that two workers facing each other do not deadlock? Is there a common pattern for resolving head-on collisions in VWAgent / multi-agent grid systems?

    I’m happy to share the __handle_collision method if needed.

    Continue reading...

Compartilhe esta Página