← MAIN
MULTI-AGENT PATHFINDING

WAREHOUSE

Robots drive from their starts to their goals without sharing a cell or swapping places.
ROBOTS 0 SUM OF COSTS — COLLISIONS — STATUS PLACE ROBOTS

HOW TO PLAY

Robots drive from their starts to their goals across a warehouse map. The goal is to route every robot so that no two robots share a cell or swap places.

Press RANDOMIZE for a solvable set of robots, then SOLVE to run the selected planner, or RACE ALL THREE to run all three on the same robots. PLAY replays the plan, and the STEP buttons move one time step at a time.

Red markers show each collision in the plan. For CBS, the constraint tree grows as the search branches, and the node it returns is marked green.

Click shelves to build aisles, or switch to robot placement.
t = —
Shelf Goal ring, in the robot's colour Robot and its trail Collision
COLLISIONS
Run a plan to see where robots would collide.
    CONSTRAINT TREE
    Solve with Conflict-Based Search to grow its constraint tree.
    Returned plan Dead end: no route
    Click a node to read its constraints and cost.
    RACE
    Conflict-Based Search
    Prioritized planning
    Independent A*
    PlannerStatusSum of costsMakespanCollisionsTime
    WAREHOUSE
    LAYOUT
    ROBOTS: 4
    PLANNER
    More settings
    SEED
    EDIT

    HOW IT WORKS

    Each robot moves to a neighbouring cell or waits in each time step, and no two robots may share a cell or swap places. The page runs three planners, which are algorithms that turn starts and goals into paths: Conflict-Based Search (CBS), which returns the plan with the lowest total travel time; prioritized planning, which plans one robot at a time; and independent A*, which plans every robot alone and ignores the rest. The topics below cover the rules, the single-robot search, each planner, the random instances, the measured results, and the budgets.

    The map and the rules

    The map is a rectangle of cells. Each cell is either a shelf, which blocks movement, or floor, which a robot can enter. Two floor cells are neighbours when they share an edge. Cells are numbered row by row, so the cell in column x and row y has the number c = yW + x, where W is the width of the map.1

    A robot has a start and a goal, both on floor cells. Time moves in discrete steps. In each step a robot moves to a free neighbour or waits in its cell, so it chooses one of five actions: up, down, left, right, or wait.2 A path is the list of cells that a robot occupies at steps 0, 1, 2, and so on. A robot that reaches its goal stays there. The position at any step is therefore read by clamping the step to the last index of the path.3

    \pi_i(t) = \pi_i\bigl[\min(t,\ T_i)\bigr]
    3

    Here \pi_i[t] is the cell that robot i occupies at step t, and T_i = |\pi_i| - 1 is the index of its last cell. That index is the robot's arrival time: the step at which it reaches its goal and stays there.

    Two robots collide in one of two ways. A vertex conflict puts two robots on the same cell at the same step. An edge conflict, also called a swap, has two robots exchange their cells in one step. Both rules are needed. In a swap the two robots never share a cell at any step, so a check for shared cells alone would miss it.4

    \pi_i(t) = \pi_j(t) \quad\text{or}\quad \bigl(\pi_i(t{-}1) \neq \pi_i(t)\ \text{and}\ \pi_i(t{-}1) = \pi_j(t)\ \text{and}\ \pi_j(t{-}1) = \pi_i(t)\bigr)
    56

    Here the first clause is the vertex conflict between robots i and j at step t, and the second is the swap between them in the step from t-1 to t. The check runs at every step from 0 to the makespan. A robot that has arrived is a stationary obstacle, so a collision with it is still found.7 The code reports one vertex conflict for each robot that enters a cell already taken at that step, paired with the first robot there. Three robots on one cell therefore give two conflicts, not three. Each swapping pair is reported once.

    8
    function FIND-CONFLICTS(paths):
        conflicts ← []
        if paths is empty:
            return conflicts
        horizon ← makespan(paths)
        prev ← the cell of each robot at step 0
        for t in 0 to horizon:                          # every step, up to the last arrival
            now ← the cell of each robot at step t      # a robot waits at its goal after arriving
            occupant ← {}                               # cell → first robot standing on it
            for each robot i with cell c = now[i]:
                if c is in occupant:
                    append a vertex conflict at t between occupant[c] and i
                else:
                    occupant[c] ← i
            if t > 0:
                before ← {cell → the robots standing on it at step t − 1}
                for each robot i with prev[i] ≠ now[i]:  # a real move from a to b
                    a ← prev[i];  b ← now[i]
                    for each robot j in before[b], with j > i:
                        if now[j] = a:                  # j moved b → a: a swap
                            append a swap conflict at t between i and j
            prev ← now
        return conflicts

    The makespan is the largest arrival time, the step at which the last robot arrives. The sum of costs (SOC) adds the arrival times of all robots. A plan with no conflicts is collision-free. CBS minimises the sum of costs, and the page shows both numbers.

    \mathrm{SOC} = \sum_{i} T_i \qquad\qquad \mathrm{makespan} = \max_{i} T_i
    9

    Here the sum and the maximum run over all robots i, and T_i is the arrival time defined above. In the swap-corridor example below, planned alone, both robots arrive at step 4, so the sum of costs is 8.

    Space-time A*: the single-robot search

    A* is a best-first search. It always expands the state with the smallest priority f = g + h, where g is the cost so far and h is a heuristic, an estimate of the cost that remains. In space-time A*, a state is a pair of a cell and a step. A robot on the same cell at steps 3 and 4 is in two different states, and waiting is an ordinary move between them, one step long.10

    The heuristic is the walking distance: the number of moves on the shortest route from a cell to the goal, through floor cells, ignoring every other robot. A breadth-first search from the goal computes it once per goal, and the result is cached.11 Because it ignores the other robots, it never overestimates the remaining time, which makes it admissible. It also changes by at most one per step, so a successor's priority is never lower than its parent's, which makes it consistent.

    f(c, t) = t + h(c), \qquad h(c) = \text{walking distance from } c \text{ to the goal}
    1213

    Here c is a cell, t is the step at which the robot is on it, and f is the value the queue sorts on. The code pushes f = t + 1 + h for each successor, since a successor is one step later.

    A reservation table holds what the search must respect. A vertex block (c, t) keeps the robot off cell c at step t. An edge block (a, b, t) forbids the move from a to b that arrives at step t, which is how a swap is stopped. A parked cell is the goal of a robot that has already arrived, and it stays blocked from that step onward.14 A robot may stop at its goal only if the goal is not parked and no vertex block on it comes at or after the step.

    \mathrm{stay}(g, t) \iff g \notin \text{parked} \ \text{and}\ \mathrm{last}(g) < t
    15

    Here \mathrm{last}(g) is the latest step at which g has a vertex block, or -1 if it has none. The search returns the first state it pops that is a goal state with \mathrm{stay}(g, t) true. Since the heuristic is zero at the goal, that state has the smallest arrival time among valid goal states: every state with a smaller priority was popped before it. A goal state that fails the stay test is not a solution, so the search continues past it.

    Example. On a one-row corridor of six floor cells, a vertex block on cell 2 at step 2 forces the robot to wait once on cell 1. Its path is 0, 1, 1, 2, 3, 4, 5, so it arrives at step 6.16

    The search looks ahead only to a horizon H, the largest reserved step plus the number of cells plus one. The number of cells is the width times the height, shelves included, so the bound is loose. After the largest reserved step, only parked cells can still block, and a robot that is still moving then can walk to its goal in fewer steps than there are cells.17

    H = t_{\max} + |V| + 1
    17

    Here t_{\max} is the largest step with a reservation (max_time()), and |V| is the number of cells in the map (grid.size).

    1819
    function SPACE-TIME-ASTAR(grid, start, goal, res):
        h ← walking distance from each cell to goal        # ignores the other robots
        queue ← [(start, step 0)], ordered by f = step + h
        while queue is not empty:
            (cell, t) ← the state in queue with the smallest f
            if cell = goal and res allows the robot to stay at goal from step t:
                return the cells from start to (cell, t)
            for each nxt in cell and the neighbours of cell:    # wait, or move
                if (nxt, t + 1) is not blocked and was not seen before:
                    add (nxt, t + 1) to queue
        return none                                          # no path within the horizon

    The parent table. parent does two jobs. It records each state once, so no state is pushed twice, and it stores the state each one was reached from, so the path can be rebuilt by walking back from the goal.

    Ties. Entries are ordered by (f, -t). Among states with the same f, the one with the larger step has the smaller key, so the deeper state is popped first and reaches the goal with fewer expansions.

    Blocked moves are dropped when generated. A successor that is blocked, unreachable, or already present is never pushed, so the queue holds only states that could be part of a plan.

    Conflict-Based Search

    Conflict-Based Search (CBS; Sharon et al., 2012) splits the problem into two levels.20 The low level plans a single robot with space-time A*, under only the constraints that name that robot. The high level searches a constraint tree. Each node holds a set of constraints, one path for every robot, and the cost of those paths. The root has no constraints, so every robot takes its own fastest path.21

    The cost of a node is its sum of costs. Because a constraint can only keep a robot away from a cell or a move, a replanned robot never arrives earlier than before. So the cost never falls from parent to child, and the root cost is a lower bound on every node.22

    C(N) = \sum_i T_i(N), \qquad C(\text{child of } N) \ge C(N)
    2324

    Here C(N) is the sum of costs of the paths held by node N, and T_i(N) is the arrival time of robot i in that node.

    A constraint is one of two kinds. A vertex constraint (i, c, t) says that robot i may not be on cell c at step t. An edge constraint (i, a, b, t) says that robot i may not move from a to b so as to arrive at step t.25

    (i, c, t):\ \pi_i(t) \neq c \qquad\qquad (i, a, b, t):\ \neg\bigl(\pi_i(t{-}1) = a \ \text{and}\ \pi_i(t) = b\bigr)
    25

    To expand a node, the high level takes its first collision: the earliest step at which two robots collide, with a vertex conflict before a swap at the same step. The node then gets two children. For a vertex conflict at cell c and step t between robots i and j, one child adds (i, c, t) and the other adds (j, c, t). For a swap in which i moves from a to b while j moves from b to a at step t, one child adds (i, a, b, t) and the other adds (j, b, a, t). Each child replans only the robot it constrains, and its cost is the new sum of costs. A child with no path within the horizon is a dead end and is not added to the tree.26

    Open nodes wait in a priority queue ordered by cost, with ties broken by creation order, so the cheapest node is expanded first. A node with no collisions is a plan, and the search returns it when it is popped. This is optimal because the root cost bounds every node, and each collision must be resolved by at least one of its two children. The first collision-free node expanded is therefore the cheapest possible plan.22

    Example. On the swap corridor, a row of five floor cells with one pocket above the middle cell, the two robots exchange ends. Planned alone, each takes four steps, so the root has cost 8. The first collision is a vertex conflict on the middle cell at step 2. Each of its two children costs 9. The plan the search returns has cost 11: robot 0 waits once, and robot 1 steps into the pocket to let it pass, so the arrival times are 5 and 6.

    2728
    function CBS(problem):
        root ← every robot planned alone by SPACE-TIME-ASTAR
        open ← [root], ordered by cost (the sum of arrival times)
        while open is not empty:
            node ← the cheapest node in open
            conflict ← the earliest collision in node.paths
            if there is no conflict:
                return node.paths                  # collision-free, and cheapest
            for each (robot, constraint) in BRANCH(conflict):
                child ← node plus constraint, with only that robot replanned
                add child to open
        return no plan

    Stored nodes. A node keeps its whole constraint set and its whole set of paths. A child copies its parent's constraints and replaces the one path it constrains, so no other robot is replanned.

    Budgets. The search stops with a status instead of an error: node_limit after the expansion budget, time_limit after the time budget, and no_solution when the queue empties. Infeasible instances usually end on a budget, because a constraint only limits when a robot may be somewhere, so the tree can keep branching. The page uses 2,000 nodes and 2.0 s. The core defaults are 2,000 nodes and 5.0 s. The node budget counts expansions, while the panel also shows the number of nodes created.29

    The trace. The first trace_limit expansions are recorded with each child's id and cost, which is what the constraint-tree panel draws. The returned plan is identified by the id of its node, so the panel can mark it.30

    Prioritized planning

    Prioritized planning plans the robots one at a time, in index order by default. Robot 0 is planned first, with nothing to avoid. Each later robot is planned against a reservation table that holds every earlier path: their cells, their moves, and their goals, where they park. Each new path is searched to avoid everything already reserved, so every returned plan is collision-free by construction.31

    Two costs follow from planning greedily. A robot can have no route at all once the robots before it block the way, and the result is then the status failed with no plan. The early robots also take their fastest routes without regard to the later ones, so the total cost can be higher than the optimum. No robot is replanned in a different order.32

    3132
    function PRIORITIZED(problem):
        reserved ← empty reservation table
        for each robot r in order:                        # index order by default
            path ← SPACE-TIME-ASTAR(start_r, goal_r, reserved)
            if path is none:
                return status "failed"
            reserved ← reserved plus the cells, moves and parked goal of path
        return the paths, one for each robot

    One table for all robots. The table is shared, so the last robot is planned against every earlier path at once. A path also reserves its own goal from its arrival step onward, so a later robot cannot pass through a robot that has already parked.

    Independent A* (baseline)

    Independent A* runs the single-robot search for every robot with an empty reservation table, so each robot ignores the others. It is the fastest of the three, but its paths can collide. Its status is collisions, and the page draws the paths and flashes each collision in red on the step where it happens.33 Its sum of costs looks lowest in the benchmark below only because its plans are invalid.

    33
    function INDEPENDENT(problem):
        for each robot r:
            paths[r] ← SPACE-TIME-ASTAR(start_r, goal_r, empty reservation table)
        conflicts ← FIND-CONFLICTS(paths)
        if conflicts is empty:
            return status "solved", with the paths
        return status "collisions", with the paths and the conflicts

    Random instances (RANDOMIZE)

    RANDOMIZE draws starts and goals from the largest connected floor region, so that every robot can reach every cell. Some draws are infeasible, because robots can block one another into a dead end. Each candidate is therefore checked with CBS under a node budget, and only candidates that CBS solves are kept. The seed fixes the draw. The check is deterministic unless CBS runs out of time, since the time budget depends on the machine.34 The server tries 10 candidates at 800 nodes and 0.4 s each, and the page tries up to three seeds.3536

    34
    function RANDOM-INSTANCE(grid, robots, seed):
        floor ← the cells of the largest connected floor region
        rng ← random generator with the given seed
        repeat attempts times:
            cells ← 2 × robots distinct cells drawn from floor
            problem ← the first half of cells as starts, the second half as goals
            if CBS(problem) is solved within its budget:
                return problem
        raise an error: no solvable instance

    Results

    Both tables come from committed benchmark runs. Each run uses random instances from consecutive seeds, and every planner runs on the same instance. The means are plain averages over the instances, and the timings are left out because they depend on the machine.373839 A rerun of both commands on 2026-10-09 gave the same costs, collision counts, and solved counts.

    \overline{x} = \frac{1}{n}\sum_{s=1}^{n} x_s
    40

    Here n is the number of instances and x_s is the value on instance s. For the sum of costs, the average uses only the instances in which the planner returned a plan. Collisions are averaged over all instances.

    Bottleneck, 6 robots, 10 instancesSolvedMean SOCMakespanCollisionsCBS nodes
    Conflict-Based Search10/1052.915.50.00693.6
    Prioritized planning10/1055.915.70.00-
    Independent A*0/1047.714.33.80-

    Prioritized planning was suboptimal on 5 of the 10 instances where both it and CBS solved, by 3.00 on average.41

    Shelf aisles, 8 robots, 10 instancesSolvedMean SOCMakespanCollisionsCBS nodes
    Conflict-Based Search10/1075.717.40.00135.0
    Prioritized planning10/1079.517.10.00-
    Independent A*0/1072.917.03.50-

    Prioritized planning was suboptimal on 9 of the 10 instances where both it and CBS solved, by 3.80 on average. "CBS nodes" is the mean number of tree nodes created, the root included.42

    Rules and budgets

    Rule or budgetWhat it controlsValue
    Moves per stepOptions for each robot in each time stepUp, down, left, right, or wait
    ConflictsWhat the planners forbidTwo robots on one cell; two robots swapping cells
    A* heuristicDistance guess to the goalShortest walking distance on the map, ignoring other robots (breadth-first search)
    A* horizonLatest step a search may reachLargest reserved step + number of cells + 1
    Page SOLVE budget (CBS)Nodes and seconds per solve2,000 nodes, 2.0 s
    Server defaults and capsLimits the web API acceptsDefault 1,500 nodes, 2.0 s; cap 3,000 nodes, 3.0 s
    Core CBS defaultsCLI and benchmark solves2,000 nodes, 5.0 s; trace keeps up to 200 nodes (the page gets 120)
    RANDOMIZE checkCBS run on each candidate start and goal set10 candidates at 800 nodes and 0.4 s each; the page tries up to 3 seeds
    Benchmark generationCBS check on each random instanceUp to 30 attempts; the benchmark passes 2,000 nodes and 5.0 s
    Robot and map capsWeb API limits1 to 8 robots; maps 3 to 24 wide and 2 to 16 high
    Built-in mapsLayouts on the pageShelf aisles 16 × 10; crossroads 11 × 9; bottleneck 13 × 7

    How these were chosen: Nothing here is learned or tuned, and the repository has no tuning code for these values. The heuristic is the exact shortest walking distance, so there was no value to pick. The budgets are constants set by hand. The server gives the reasoning: a RANDOMIZE draw costs at most 10 × 0.4 s, about 4 s, and the map and robot caps exist because the planners bound time but not size.4344