bugger.
RL environments/Pythonmediumrl-parallel-aisle-v1
IMPLEMENTATION LAB

Resolve simultaneous moves in a shared aisle

Resolve collisions against a common snapshot instead of iterating one robot at a time.

RL Environments

Your task

Two robots occupy distinct unblocked cells in a one-dimensional aisle. Input has aisle length, walls (blocked cell numbers), positions (two cells, in robot order), and moves (two integers from -1, 0, 1). Compute both proposals from the original positions. A move past an edge or into a wall becomes a stay. If both proposals target the same cell or swap the two starting cells, both robots stay and conflict is true. Otherwise apply both proposals and set conflict to false. Return positions in the original robot order and conflict.

Expected behavior

A robot may follow another into a vacated cell. Both robots stay for conflicting destinations and head-on swaps.

Examples

01 Both robots target the same cell
{"length":5,"walls":[],"positions":[0,2],"moves":[1,-1]}
{"positions":[0,2],"conflict":true}
02 A follower enters a vacated cell
{"length":5,"walls":[],"positions":[0,1],"moves":[1,1]}
{"positions":[1,2],"conflict":false}
03 Both robots stay
{"length":5,"walls":[],"positions":[1,2],"moves":[0,0]}
{"positions":[1,2],"conflict":false}

Before you begin

  • Python functions, lists, and dictionaries

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    Run the examples, then submit to check the full contract.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.