Skip to main content

deadlock_room

Function deadlock_room 

Source
fn deadlock_room(burrow: &Burrow, kind: usize) -> bool
Expand description

Detects situation where amphipods in the hallway need to move past each other but mutually block any further progress.

For example:

#############
#.....D.A...#
###.#.#.#.###
  #.#.#.#.#
  #.#.#C#.#
  #.#.#C#.#
  #########

In this situation, neither A nor D can move into C’s room but also block each other from returning to their home burrow.

Another example:

#############
#.....C.A...#
###.#.#.#.###
  #.#.#.#.#
  #.#.#B#.#
  #.#.#C#.#
  #########

In this situation C blocks A from returning to its home burrow and B is also blocked from moving out of the way.