The Pirate Loop is a BBC Books original novel written by Simon Guerrier and based on the long-running science fiction television series Doctor Who.
After escaping from over-eager serving robots in Milky-Pink City, Martha asks the Doctor about the Starship Brilliant, which mysteriously disappeared.
She wakes in the ship's engine room, where she and the Doctor are led to the starship's experimental drive by the slave-like mechanics, who have small holes instead of mouths.
They attempt to contact the captain, but find that the door out of the engine rooms is blocked with a membrane like scrambled egg.
The Doctor notes that it separates regions where time flows at different rates, and uses his sonic screwdriver to allow them to pass through.
Martha learns that the ship has been invaded and asks Gabriel to warn the Doctor, but three badger-faced space pirates enter and disintegrate him.
On emerging from the scrambled egg membrane, the Doctor is met by Gabriel, who tells him that Martha has gone to the cocktail lounge.
Jocelyn blocks off the corridor by activating the fire doors, then escorts the Doctor to Dashiel in the cocktail lounge.
Dashiel attacks the Doctor after he is tricked into disabling the guns using the sonic screwdriver, but runs into the window and is knocked unconscious.
The Doctor takes his dagger and heads to the bridge with Mrs Wingsworth and Archibald, leaving Jocelyn to tend to Dashiel.
He explains that they are in a time loop, and the ship is attempting to protect the passengers by resurrecting them and replenishing the food, using its drive to alter reality.
The Doctor uses the transmat booth to travel back to the engine room so that they can escape from the time loop, connecting the ship's drive to the TARDIS and using it to warp space-time.
He leaves a note for Gabriel and is found by Mrs Wingsworth, who tells him that people have stopped coming back to life.
The pirate ship destroys the Brilliant on Captain Florence's orders as they arrive, and she shoots Mrs Wingsworth and Archibald.